Keycloak SSO with onLoad: 'login-required', redirects to keycloak server on page refresh

Hi All,

I am able to SSO to keycloak server using following configuration onLoad: ‘login-required’, it works fine, however on each page refresh, it redirects me to Authentication redirect and takes back me to app.

I want to prevent authentication redirect. Any advice will be greatly appreciated.

Hi.

If you think about it, the application have no other way to check if the user is still logged in but to ask the server (because the user could have been logged out, or the user logged out in another application, if this is a single sign on scenario).

So, Keycloak adapters have two ways to check for centralized logout: iframes and redirects.

I’m no expert, but I believe the iframe way is getting harder and harder to work properly, because of browser restrictions.

The other way is a redirect, where every time you need to check if the user is logged in, you just redirect it to the authentication server and if he comes back ok, it’s logged in, if not, is logged out.

There is a parameter for that called prompt. If prompt is set to none, them the server will show no interface to the user, just redirect him back with an error.

So, you can configure you adapter to onLoad: 'check-sso' and check if that is ok to you. You’ll have to deal with the case when the user is not logged in (check the docs for that).

Hi Weltonrodrigo,

Please note that I am using sso with keycloak and check-sso it fails for some reason. Prompt option is not available in keycloak.js initoptions.
Thanks for your prompt reply, in my case I am using logged-in because check-sso gives me 401 error on userProfile call. I will try with prompt set to none and see what response i get.

Thanks
Sanjay