# Blazor WASM permission based Authorization

**URL:** <https://community.auth0.com/t/blazor-wasm-permission-based-authorization/94743>\
**Category:** Dev to Dev Hub\
**Tags:** ticket-management, support-center\
**Created:** [November 19, 2022, 3:46am UTC](https://community.auth0.com/t/blazor-wasm-permission-based-authorization/94743 "2022-11-19T03:46:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![p.hezaveh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/p.hezaveh/32/17327_2.png) [@p.hezaveh](https://community.auth0.com/u/p.hezaveh)\
**Post date:** [November 19, 2022, 3:46am UTC](https://community.auth0.com/t/blazor-wasm-permission-based-authorization/94743/1 "2022-11-19T03:46:39Z")

</div>

Wish to authorise a user based on their permission assigned by their roles (using RBAC) on Blazor. in other words display portion of UI based on user permissions. the rbac and “permission to be added” are enabled.  
We were able to get it worked on the backend (.net core 6) however we having issue for its the frontend (WASM).

After a user login to the app a cockie is saved with informations of ID-token and Access token  
ID-token has user assigned role but lack of assigned permissions  
Access token have both User roles and permission  
following has been done to setup the blazor client:  
1- added following code to the program.cs  
builder.Services.AddOidcAuthentication(options =\> {  
builder.Configuration.Bind(“Auth0”, options.ProviderOptions);  
options.ProviderOptions.ResponseType = “code”;  
options.ProviderOptions.AdditionalProviderParameters.Add(“audience”, builder.Configuration[“Auth0:Audience”]);  
}).AddAccountClaimsPrincipalFactory\<ArrayClaimsPrincipalFactory\>();

builder.Services.AddAuthorizationCore(options =\>  
options.AddPolicy(“admin”, policy =\> policy.RequireClaim(“permissions”, “read:user”)));

2- added following attr to the view page  
@attribute [Authorize(Policy = “admin”)]

after running the app the following information is written to the chrome console and the page is show that is not athorized.  
shown in the console:  
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]  
Authorization failed. These requirements were not met:  
ClaimsAuthorizationRequirement:Claim.Type=permissions and Claim.Value is one of the following values: (read:user)

after investigation found that since Authorize(Policy = “admin”) look for permissions in the ID token rather than access token, it fails.

Please advice how to overcome this issue.

---

<div class="post-metadata">

**Author:** ![rr55](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rr55/32/34965_2.png) [@rr55](https://community.auth0.com/u/rr55)\
**Post date:** [December 28, 2022, 5:12am UTC](https://community.auth0.com/t/blazor-wasm-permission-based-authorization/94743/2 "2022-12-28T05:12:48Z")

</div>

Same issue. It appears the user claims aren’t populated. var scopes = context.User.FindFirst(c =\> c.Type == “scope” && c.Issuer == requirement.Issuer) from HasScopeHandler can’t find a claim.

---

<div class="post-metadata">

**Author:** ![paul.simpson](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@paul.simpson](https://community.auth0.com/u/paul.simpson)\
**Post date:** [May 16, 2023, 9:07am UTC](https://community.auth0.com/t/blazor-wasm-permission-based-authorization/94743/3 "2023-05-16T09:07:54Z")

</div>

Has anyone been able to help with this, I have the same issue, not seeing permissions in .NET 7 client app but they are available in my .NET 7 API

---

<div class="post-metadata">

**Author:** ![jeroen.penninx](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeroen.penninx/32/72251_2.png) [@jeroen.penninx](https://community.auth0.com/u/jeroen.penninx)\
**Post date:** [July 7, 2023, 8:08am UTC](https://community.auth0.com/t/blazor-wasm-permission-based-authorization/94743/4 "2023-07-07T08:08:44Z")

</div>

This seems to be by design. Id tokens dont contain permissions. Anyone at Auth0 having thoughts on this? How do I block a route, part of page or whole page based on permissions?

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [March 12, 2025, 11:25pm UTC](https://community.auth0.com/t/blazor-wasm-permission-based-authorization/94743/6 "2025-03-12T23:25:28Z")

</div>

Hi @p.hezaveh and everyone!

Indeed, the ID token does not contain claims such as the user roles. In order for you to have access to them inside the ID Token, you would need to set them as [custom claims](https://auth0.com/docs/secure/tokens/json-web-tokens/create-custom-claims) using a post login action:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const roleClaim = 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role';
  
  if (event.authorization) {
    api.idToken.setCustomClaim(roleClaim, event.authorization.roles);
  }
};

```

You can take a look at this blog post made by one of our developers, Andrea Chiarelli regarding building a WASM application with RBAC:

- [Role-Based Access Control (RBAC) in Blazor Applications](https://auth0.com/blog/role-based-access-control-in-blazor-apps/)

Hope this helps!

If you have any other questions, feel free to leave a reply or post again on the community!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 26, 2025, 11:25pm UTC](https://community.auth0.com/t/blazor-wasm-permission-based-authorization/94743/7 "2025-03-26T23:25:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![remus.ivan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/remus.ivan/32/68771_2.png) [@remus.ivan](https://community.auth0.com/u/remus.ivan)\
**Post date:** [September 5, 2025, 8:37pm UTC](https://community.auth0.com/t/blazor-wasm-permission-based-authorization/94743/8 "2025-09-05T20:37:26Z")

</div>


