Skip to content

how do I get realm information from Authentication object ? #218

Answered by ch4mpy
kommradHomer asked this question in Q&A
Discussion options

You must be logged in to vote

You can infer it from the issuer claim with a regex like ^.*/realms/([^/]+).*$.

If you want to add some helper methods to the Authentication instance in the security context (like KeycloakAuthenticationToken was doing):

  • create an Authentication implementation (you might use AbstractAuthenticationToken, JwtAuthenticationToken, or this lib's OAuthentication as base class)
  • declare a JwtAbstractAuthenticationTokenConverter bean in your conf (something that can turn a Jwt into something extending AbstractAuthenticationToken)
@Configuration
@EnableMethodSecurity()
public class SecurityConfig {

  @Data
  @EqualsAndHashCode(callSuper = true)
  public static class KommradAuthentication extends O…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ch4mpy
Comment options

Answer selected by ch4mpy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants