【问题标题】:token washed out after closing browser关闭浏览器后令牌被洗掉
【发布时间】:2018-01-23 18:27:24
【问题描述】:

我已经在我的系统中集成了身份服务器,现在我想保留身份服务器令牌,以便用户在浏览器关闭后不必重新登录。

这是我的代码。

    //Identity server
    if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"]))
    {
        IdentityServerRegistrar.Register(services, _appConfiguration);

        //BHARAT : JWT Authentication Middleware
        services.AddAuthentication().AddIdentityServerAuthentication("IdentityBearer", options =>
        {
            options.Authority = _appConfiguration["App:ServerRootAddress"];
            options.RequireHttpsMetadata = false;
            options.ApiName = "default-api";
            options.ApiSecret = "def2edf7-5d42-4edc-a84a-30136c340e13".Sha256();
            options.CacheDuration = TimeSpan.FromMinutes(30);
            options.SaveToken = true;
        });
    }

我试图遵循这个 https://github.com/IdentityServer/IdentityServer3/issues/1379

这是浏览器中的令牌快照。

我尝试了许多其他方法来保留 cookie/令牌,但它不起作用。

我是否必须在客户端添加任何内容,我使用的是 .net core 2.0 和 angular 版本。

【问题讨论】:

    标签: identityserver4 aspnetboilerplate


    【解决方案1】:

    尝试更改login.service.ts中的条件:

    // Before
    var tokenExpireDate = rememberMe
                        ? (new Date(new Date().getTime() + 1000 * expireInSeconds))
                        : undefined;
    
    // After
    var tokenExpireDate = expireInSeconds
                        ? (new Date(new Date().getTime() + 1000 * expireInSeconds))
                        : undefined;
    

    【讨论】:

    • 是的,aaron 成功了,事实上,以前我的令牌存储为会话 cookie,现在它具有时间跨度。感谢您的快速帮助..
    猜你喜欢
    • 2014-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-24
    • 1970-01-01
    • 2015-08-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多