In Keycloak, can you use a JWT to get a caller's identity?

825 views Asked by At

We would like to have users authenticate to a Slack app by providing their current Keycloak JWT as a one-time authentication procedure. This would allow us to associate their Slack user ID with their Keycloak user ID.

However, I can't find any endpoint like AWS' GetCallerIdentity within Keycloak. I have combed the docs, and the closest thing I can find is an identity token mentioned here. However, I can't find anything about how to unravel that identity token to securely gain information about its owner.

Can anyone point me in the right direction?

Thank you!

1

There are 1 answers

1
Jan Garaj On

Open ID Connect defines userinfo endpoint, which is similar to AWS GetCallerIdentity endpoint. But that requires to fire request. I would prefer to read user details from the token.

Standard JWT (OIDC) libraries support token decoding. Access/ID token has 3 parts: header, payload, signature. You can use base64 decode on the payload part and you will get json with user details. Of course proper implementation will read also header to get used algorithm and it will validates token signature with used IdP public key and algorithm. Otherwise someone can tamper token.

https://jwt.io/#debugger-io provides nice visual interface, which will help you to understand and also decode token structure:

enter image description here

Keep in mind: what is returned in the userinfo response depends on OIDC client configuration in the Keycloak