I'm trying to create a custom authorization policy. Let's say I want the URL to contain a token. For example:
https://example.com/customer/list?token=2nHxltsDOjThQJWufcGU1v36RdqYoBE9
I want to show the list of customer to the user, only if:
- URL has a token query string
- token is valid
I tried this:
services.AddAuthorization(options =>
{
options.AddPolicy("IsPaydar", policy => policy.RequireAssertion(x => // stuck here))
});
But I don't see how can I access HttpContext or the Request object from inside the policy.RequireAssertion
.
How can I implement this?