We are trying to use Auth0 for SPA application in javascript.
Authenticating using Azure connection and getting idToken on success.
The requirement is to read roles and permission for logged-in to restrict pages based on roles and permission.
Please guide us on how to achieve this.
Hi @mail4mithu,
Thanks for joining the Community!
You can add the role/permissions to the ID Token or Access Token by using a custom claim in a Rule.
Here is a related topic that shows you how to add permissions to the ID Token: Accessing the permissions array in the access token - #10 by ryantomaselli
And here is how to add the user roles to tokens: Sample Use Cases: Rules with Authorization
Let me know if you have any questions about these examples!
Stephanie
Thank you, Stephanie, for your help, I am able to get roles now. one small question can I change the name from link to roles? when I change it was not returning roles.
Hi @mail4mithu,
Any custom claims must be namespaced to be OIDC-compliant so that your claims won’t collide with reserved claims. This is typically done with a URI such as http://www.myexample.com/
.
So you can change the URI to something specific to your app, but it’s recommended that you use a URI as the namespace.
You can read more about namespacing custom claims here:
Thank you @stephanie.chamblee for your help.
No problem! Happy to help!
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.