AccessTokenManagement for Blazor server and role claims #269
Replies: 5 comments
|
Could you share a bit more about your situation?
|
|
My current solution is more or less the same as the blazor sample. I use version 3.2. The roles come from my database and currently I extend the user principal with the role claims on store in the UserStore. This works fine for the initial sign-in, but then when I check later in the day, so I think after the token has expired+refreshed these claims are gone. If I add the roles on the CookieEvents ValidatePrincipal it seems to work fine, but this event is fired a lot so that seems overkill to me. What would be your suggestion / hookup point for extending the principal you get from OIDC with additional claims? |
|
I actually found the issue why the claims where not added on token refresh so that part has been resolved. Anyway what would be your suggestion to extend the principal with additional claims? I now do this on OidcEvents.TokenValidated and JwtEvents.TokenValidated, but maybe there is a better way? |
|
Problem is, there are multiple ways to extend the claims principal: the various events during cookie or OIDC authentication, claims transformation, ... It's difficult to give an answer that fits all use cases. We are interested however in your solution if you're willing to share it: others could benefit from your solution if they happen to stumble upon this issue 🙂 |
|
I now extend my User principal in the Jwt and OIDC events like this |
Uh oh!
There was an error while loading. Please reload this page.
Situation
Question
I extend my principal object with the role claims after validation
OpenIdConnectEvents.TokenValidatedto add for example an admin role. This works perfectly fine and I see the admin related parts in Blazor Server. But after some time I think the token refresh the role claims are dropped and the role specific parts of Blazor are hidden.What is the correct way (on which events) when using 'AccessTokenManagement.OpenIdConnect' I should extend my principal with the role claims?
All reactions