I am looking to use Okta for authentication, then attach application defined role claims to my principals post-login. I know I can define groups/roles within my okta configuration, but I am looking for an alternate approach.
I have integrated this successfully within e.g. a MVC (or any other SSR type) app, but with a SPA → API architecture & SSO, there are additional challenges. This comes primarily in the effect of extra requests to the back end and/or database to query the roles associated with the user.
My current approach is as follows:
I am using C# Blazor WebAsm client, .NET 6.0 API backend
- Authenticate with Okta, receive claims + API token
- Query backend for role assignments and attach to front end principal (using AccountClaimsPrincipalFactory)
- For each request to API, query for roles and attach to principal (using IClaimsTransformation)
Is it a possible (and more importantly, secure) approach to rather do as follows:
- Authenticate with Okta, receive claims + API token
- Query backend for role assignments once, create new token for all subsequent API requests
Does this involve just creating a new JWT from scratch on the front end and throwing the one from Okta away once we’ve authenticated?
Thank you,
Brandon