关闭浏览器后令牌被冲掉

token washed out after closing browser

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

这是我的代码。

    //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/token 但它不起作用。

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

尝试更改 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;