I’m developing a javascript project using keycloak for authentication, and I’d like the contents of the application to change depending on the type of user who logs in. For example:
If the user is as user, it will show on the screen that he is a user
If the user is as admin, it will show on the screen that he is an admin
Some approaches here. Let’s say you identify the rights based on Keycloak (KC) roles:
- OAuth 2.0 Approach: You can add the user’s roles to the access token and utilize them when your app calls your APIs (where your APIs act as OAuth 2.0 RS).
- OIDC Approach: You can add the user’s roles to the ID token, thereby enriching the identity information.
You can also combine both approaches as needed, or add that information to the userinfo endpoint.