1

I am using angular 5 with oidc-client and identity server 4. Is session timeout supported in oidc-client or i need to implement it manually ?

By Session Timeout i mean, the user will be logged out after sometime of inactivity

Jek
  • 441
  • 7
  • 16

1 Answers1

0

for your SPA applications you can use the implicit flow, refresh token is not possible automatically but oidc-client.js can make it easy for you. you can use the silent refresh, oidc-client will send the active cookie session to get a new access_token just before the expiration of the new one. you need only to configure it

const config = {
  authority: xxxxx,
  client_id: xxxxx,
  popup_redirect_uri: `${OidcConfig.clientRoot}/assets/html/popup-login-redirect.html`,
  scope: 'openid profile',
  response_type: 'id_token token',
  post_logout_redirect_uri: `${OidcConfig.clientRoot}?postLogout=true`, // delet all stored tokens after logout
  userStore: new WebStorageStateStore({ store: window.localStorage }),
  automaticSilentRenew: true, // enable silent refresh
  silent_redirect_uri: `${OidcConfig.clientRoot}/assets/html/silent-refresh-redirect.html` // here when you can get the new tokens
};

here is the content of silent-refresh-redirect.html

  <script src="https://cdnjs.cloudflare.com/ajax/libs/oidc-client/1.5.1/oidc-client.min.js"></script>
  <script>
  var config = {
     userStore: new Oidc.WebStorageStateStore({ store: window.localStorage })
  };
  new Oidc.UserManager(config).signinSilentCallback()
    .catch((err) => {
        console.log(err);
    });

  </script>
Fateh Mohamed
  • 20,445
  • 5
  • 43
  • 52
  • Thanks @Fateh, i need the session to expire after sometime of inactivity. Is this available out of the box, or i need to monitor his activity manually and log him out ? – Jek Sep 20 '18 at 16:18
  • @Jek Did you figure out the answer? I'm currently on the way of implementing this. – Narshe Jun 20 '19 at 14:35
  • 1
    @Narshe we implemented out own solution by monitoring the user KeyDown and MouseMove events. The MouseMove is delayed 1 sec between each move to avoid performance issues – Jek Jun 25 '19 at 07:02