Skip to content

Adding a policy will always fail authorization #29

@lsbrettjewell

Description

@lsbrettjewell

In this modified snippet from the Isolated-Net6 sample, adding any policy will cause authorization to always fail.

services.AddOpenIDConnect(config =>
{
    var audience = Environment.GetEnvironmentVariable("OpenIdConnect_Audience");
    var issuer = Environment.GetEnvironmentVariable("OpenIdConnect_Issuer");
    var issuerUrl = Environment.GetEnvironmentVariable("OpenIdConnect_IssuerUrl");

    config.SetTokenValidation(TokenValidationParametersHelpers.Default(audience, issuer));
    config.SetIssuerBaseUrlConfiguration(issuerUrl);

    config.AddPolicy("DefaultPolicy", policy =>
    {
        policy.RequireClaim("scope", "myscope");
    });
});

It would seem no IAuthorizationHandler for the policy is added to the IAuthorizationService. Looks like same issue is reported here #18.

What is the intended way to add a policy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions