[keycloak-user] Keycloak: Get Locale used at loginpages localeswitch in application via Wildfly adapter

Dominik Guhr pinguwien at gmail.com
Tue Feb 20 04:55:02 EST 2018


Hi everyone,

another day, another question:

So I am using Keycloak w/ the wildfly adapter and internationalization 
enabled for my application.

What I want to achieve:

1. User gets to kc loginpage
2. user switches the locale (using keycloaks ftl locale dropdown here on 
a custom theme)
3. user logs in
4. a phaselistener (jsf used) is set up and checks the kc login. Here I 
have access to idToken and securityContext etc. via clientadapter.

My Problem:
In the app itself, there's a locale witch, too. I want to use the locale 
provided at login in my app, therefor I need to sync these two locales 
(keycloak is leading system).

What I've tried:

1. Setting up a mapper for the builtin locale and check it in my 
phaselistener. Problem: this locale doesn't change, even when I switch 
languages before login. e.g.:
  - I switch language to "en" in loginpage
  - I login with my credentials
  -  getIdToken().getLocale() says "de"

2. looking in the context for another localefield, but didn't find one

Could anyone tell me how to achieve this? I really don't like to add a 
cookie to the request myself via js or something, for this should work 
with the adapter I think.

Thanks and best regards,
Dominik


More information about the keycloak-user mailing list