[keycloak-user] Guest account

Corentin Dupont corentin.dupont at gmail.com
Tue Mar 6 14:11:35 EST 2018


Hi all,
I have a javascript web app using keycloak for authentication.
When the user opens the app, he is first redirected to the Keycloak login
screen.
However it's a bit annoying for the user to have to create an account
before seeing anything.
Personally I close this kind of application :)

I would like that the application uses a "guest" account if the user is not
registered.
"guest" is a real keycloak account that have particular access rights.
How to do that? My application probably needs to provide login/password for
guest and store the token.
I use keycloak-js library. Now my login code is standard:


 var keycloak = Keycloak({
    url: config.keycloakUrl,
    realm: config.realm,
    clientId: config.clientId
  });

  keycloak.init({ onLoad: 'login-required', checkLoginIframe: false
}).success(authenticated => {
    if (authenticated) {
      store.getState().keycloak = keycloak;
      setInterval(() => {
        keycloak.updateToken(3600).success(function (refreshed) {
            getSensors();
            getUsers();
          }).error(function () {
            alert('Your session has expired, please log in again');
            keycloak.logout();
          })
        }, 10000);

      displayPage();
    }
  }).error(function (error) {
    console.log("Authentication error. Check Keycloak params and cors
issues.");
  });


More information about the keycloak-user mailing list