I have 2 JHipster apps running each on one subdomain (app1.domain.tld & app2.domain.tld).
In both apps, users login through Keycloak. The sequence is as such :
- Angular app sends /authenticate request with credentials to Keycloak
- In case of successful response returns a authentication cookie
- POST request is is sent to Jhipster backend app that generates JSessionID cookie
- JSessionID is then used for every request to backed app.
What would be the best way to automatically login user (without asking username & password) if they are already logged in one of the apps of the domain (*.domain.tld) ?
I tried to use the JSessionID as a global token before understanding it only works on the app it was generated on...
Maybe catching Keycloak authentication cookie (returned at step 2) and authenticating on second application would do the trick ?
From what I saw while testing, after being authenticated on first app, when I go to the second one, Angular 401 HTTP interceptor redirects to keycloak login page with a session token. Thus at that time Keycloak should see that I'm already logged in and should redirect me to home page of my second app.
Am I right ?