blazor sample ujsing cliam policy 1

blazor sample ujsing cliam policy

public void ConfigureServices(IServiceCollection services)
{
    services.AddAuthorization(config =>
    {
        config.AddPolicy("IsDeveloper", policy => policy.RequireClaim("IsDeveloper", "true"));
    });
}

Here is what the above code is Doing:
1. We’re adding a new policy called IsDeveloper.
2. We’re requiring that the IsDeveloper claim be present and that it have a value of true.

Now that we have our policy, we can use it in our controllers.

Similar Posts