0

I'm trying to configure my application to use keycloak as authentication server, it kinda work, I was able to login successfully but when access token expires it redirects me to keycloak sign in page to login again, can anyone tell me how can I keep the session logged in without re-login again?, I've check the documentation but I can't find anything about that.

I'm using keycloak-connect package

...
const keycloakConfig = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../keycloak.json')).toString())

const memoryStore = new session.MemoryStore()

app.use(session({
  secret: process.env.EXPRESS_SESSION_SECRET,
  resave: false,
  saveUninitialized: true,
  store: memoryStore
}))

const keycloak = new Keycloak({
  store: memoryStore
}, keycloakConfig)


app.use(keycloak.middleware({
  admin: graphqlPath,
  logout: '/logout',
}))

app.get('/login', keycloak.protect(), function(req, res){
  testGrant = (req as any).kauth
  res.send("You've logged in successfully");
});
...
lawayben
  • 33
  • 1
  • 8

1 Answers1

1

Recommended way you can use the refresh token to get new access token. Also, note that the refresh token may expire, in which case you will need to sign-in again to obtain another refresh token. Also maybe you can increase token expiration times from realm settings.

isik_hi
  • 89
  • 5