首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用SPA和oidc-js的会话超时

使用SPA和oidc-js的会话超时
EN

Stack Overflow用户
提问于 2018-08-17 02:51:42
回答 1查看 1.6K关注 0票数 1

我正在使用angular 5和oidc-client和身份服务器4。oidc-client支持会话超时吗?还是需要我手动实现?

所谓会话超时,是指用户在一段时间不活动后将被注销

EN

回答 1

Stack Overflow用户

发布于 2018-09-07 07:31:56

对于您的SPA应用程序,您可以使用隐式流,刷新令牌不可能自动,但oidc-client.js可以为您提供方便。您可以使用静默刷新,oidc-client将在新的access_token到期之前发送活动cookie会话以获取新的cookie。您只需对其进行配置

代码语言:javascript
复制
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
};

以下是silent-refresh-redirect.html的内容

代码语言:javascript
复制
  <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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51883626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档