How I get user permissions in ASP.NET Core MVC

Hi, below my code

services.Configure<CookiePolicyOptions>(options =>
            options.CheckConsentNeeded = context => true;
            options.MinimumSameSitePolicy = SameSiteMode.None;

        // Add authentication services
        services.AddAuthentication(options => {
            options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        .AddOpenIdConnect("Auth0", options => {
            options.Authority = $"https://{Configuration["Auth0:Domain"]}";
            options.ClientId = Configuration["Auth0:ClientId"];
            options.ClientSecret = Configuration["Auth0:ClientSecret"];
            options.ResponseType = OpenIdConnectResponseType.Code;
            options.CallbackPath = new PathString("/Home");
            options.ClaimsIssuer = "Auth0";
            options.Events = new OpenIdConnectEvents
                OnRedirectToIdentityProviderForSignOut = context =>
                    context.ProtocolMessage.SetParameter("audience", Configuration["Auth0:Audience"]);
                    return Task.FromResult(0);

In my controller, when I use the instruction User.Claims, I do not see the permissions that I put to user

Hi @salmeidabatista,

Welcome to the Community!

If you have configured role based access control for your API, then the permissions will be included in the access token. I think the user claims you are referring to here would be from the id token or userinfo enpoint, which would not include the permissions claim.

Hope this helps!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.