问题描述
我在我的前端应用程序中使用oidc-client和angular 10,在身份验证和授权中使用identityserver4。
我无法理解令牌的有效期限。
我想做的是
1-保持活动用户登录。
2-闲置的用户应在一段时间后自动退出系统(例如:5分钟)
现在发生的事情是在闲置5分钟后,oidc客户端将我重定向回登录回调。
在我的配置文件中,这是我设置令牌生存期的方式:
new Client {
ClientName="Test",ClientId="client-spa",AllowedGrantTypes = GrantTypes.Code,AlwaysIncludeUserClaimsInIdToken = true,RedirectUris = new List<string>() { "https://localhost:44383/signin-callback" },PostlogoutRedirectUris = {"https://localhost:44383/signout-callback" },AllowedCorsOrigins = { "https://localhost:44383" },AccesstokenLifetime = 60 * 5,//5 minutes
AllowedScopes = {
IdentityServerConstants.StandardScopes.OpenId,IdentityServerConstants.StandardScopes.Profile
},}
这是我在启动文件中的cookie寿命:
var builder = services.AddIdentityServer(options =>
{
options.Events.raiseerrorEvents = true;
options.Events.Raise@R_407_4045@ionEvents = true;
options.Events.RaiseFailureEvents = true;
options.Events.RaiseSuccessEvents = true;
options.UserInteraction.LoginUrl = "/Account/Login";
options.UserInteraction.logoutUrl = "/Account/logout";
options.Authentication = new Authenticationoptions()
{
CookieLifetime = TimeSpan.FromMinutes(5),CookieSlidingExpiration = false
};
这是oidc-client的配置
const idServerSettings = {
authority: Constants.stsAuthority,client_id: Constants.clientId,scope: 'openid profile',response_type: 'code',redirect_uri: `${Constants.clientRoot}signin-callback`,post_logout_redirect_uri: `${Constants.clientRoot}signout-callback`,store: new WebStorageStateStore({ store: localStorage }),automaticSilentRenew: false,loadUserInfo: true
};
并且,我非常感谢任何解释令牌有效期的文档。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)