'How to get group and group attributes in Keycloak
I am using Spring Boot, Bitnami/Keycloak:latest, java 11.
I want to get the group and group attributes before the request reaches the controller because I need this information in every route while processing the request.
One option is to add @AuthenticationPrincipal Jwt principal to the controller, but again this piece of code where it gets the group and group attributes should be duplicated for each controller. this doesn't make sense to me.
Another option is to add group and group attributes to the token, but again I hesitate to implement this because of the cache. It may not be updated frequently. Group and group attributes should be precise in my case.
So I thought of writing an interceptor that reads the token, and by using the Keycloak client, it can reach the group and their attributes.
Is it the best option, but what do you think? What would be the best practice on this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
