我正在使用angular 5和oidc-client和身份服务器4。oidc-client支持会话超时吗?还是需要我手动实现?
所谓会话超时,是指用户在一段时间不活动后将被注销
发布于 2018-09-07 07:31:56
对于您的SPA应用程序,您可以使用隐式流,刷新令牌不可能自动,但oidc-client.js可以为您提供方便。您可以使用静默刷新,oidc-client将在新的access_token到期之前发送活动cookie会话以获取新的cookie。您只需对其进行配置
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的内容
<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>
https://stackoverflow.com/questions/51883626
复制相似问题