fmichellonet/AzureFunctions.Extensions.OpenIDConnect

Adding a policy will always fail authorization

Opened this issue · 1 comments

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?

This seemed to work exactly as expected in v0.71 Snowdrop, but was broken in the following release and ever since....