Skip to content

Best way to access the user ID #135

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

You must be logged in to vote

Few things to note:

  • The user subject (sub claim) is unique for a given authorization server and is rarely shared across authorization servers. This means that a user is very likely to have several subjects in multi-tenant environments (several Keycloak realms or identities served by several OpenID Providers like in most of this repo samples). You can use Keycloak subject as an identifier in your Spring application if and only if you are using a single Keycloak realm and will use it forever. Switching to another OP would probably be a hell as it won't know about Keycloak subjects. Using a domain identifier in Spring application is probably a better idea (something like an e-mail, a client…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by mikoet
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