Skip to content

Commit

Permalink
Add missing registration for authentication handler (#32152)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamil-sadigov committed Apr 29, 2021
1 parent 1cbd507 commit 3e46e68
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ public void ConfigureServices(IServiceCollection services)
.AddAuthentication(SampleAuthenticationSchemes.CustomScheme)
.AddScheme<AuthenticationSchemeOptions, SampleAuthenticationHandler>(SampleAuthenticationSchemes.CustomScheme, o => { });

services.AddAuthorization(options => options.AddPolicy(SamplePolicyNames.CustomPolicy, policy => policy.AddRequirements(new SampleRequirement())));
services.AddAuthorization(options => options.AddPolicy(SamplePolicyNames.CustomPolicyWithCustomForbiddenMessage, policy => policy.AddRequirements(new SampleWithCustomMessageRequirement())));
services.AddAuthorization(options =>
{
options.AddPolicy(SamplePolicyNames.CustomPolicy, policy =>
policy.AddRequirements(new SampleRequirement()));
options.AddPolicy(SamplePolicyNames.CustomPolicyWithCustomForbiddenMessage, policy =>
policy.AddRequirements(new SampleWithCustomMessageRequirement()));
});

services.AddTransient<IAuthorizationHandler, SampleRequirementHandler>();
services.AddTransient<IAuthorizationHandler, SampleWithCustomMessageRequirementHandler>();
services.AddTransient<IAuthorizationMiddlewareResultHandler, SampleAuthorizationMiddlewareResultHandler>();
}

Expand Down

0 comments on commit 3e46e68

Please sign in to comment.