I'm hoping to add the authenticating user's IP address to the JWT token for later use in the middleware. What is the easiest way to accomplish this?
Keycloak v6.0.1
I'm hoping to add the authenticating user's IP address to the JWT token for later use in the middleware. What is the easiest way to accomplish this?
Keycloak v6.0.1
Client Address
is not available in the user session note, unless the user is a Service Account (private client) - Relevant Documentation.
Easiest way to achieve this is to write a plugin for keycloak, adding an event listener on user login/token refresh to add to the user session notes. Created this quick example - https://github.com/CharlyRipp/keycloak-user-details-provider.
Note this example is for keycloak 15 (at the time of this answer) - changing the POM parent to the desired version, then may need to fix getRealm
and getUserSession
calls as those have changed in recent versions.