I want to add custom policies for two-step authorization, so after the first step user will have access to second step, and after that to everything. When I had one policy everything worked fine, but when I added another I started getting this error. How I add policies:
AuthorizationOptions authOptions = new AuthorizationOptions();
authOptions.AddPolicy("FirstStepCompleted", policy => policy.RequireClaim("FirstStepCompleted"));
authOptions.AddPolicy("Authorized", policy => policy.RequireClaim("Authorized"));
services.AddAuthorization(o => o = authOptions);
When I had one policy, I added it like this:
services.AddAuthorization
(
options => options.AddPolicy("FirstStepCompleted",
policy => policy.RequireClaim("FirstStepCompleted"))
);
What am I doing wrong?
UPD1. Forgot the exception:
An unhandled exception occurred while processing the request. InvalidOperationException: The AuthorizationPolicy named: 'FirstStepCompleted' was not found. Microsoft.AspNetCore.Authorization.AuthorizationPolicy.CombineAsync(IAuthorizationPolicyProvider policyProvider, IEnumerable authorizeData)