【发布时间】:2017-07-24 02:44:03
【问题描述】:
我正在使用 Identity Server 4 来保护我的 API(隐式流模式),这些 API 由 Angular 应用程序访问。一切正常,但是在特定时期,访问令牌甚至在到期之前就突然失效了。
配置:
这是 Identity Server 启动文件:
var identityBuilder = services.AddIdentityServer().AddInMemoryStores().SetTemporarySigningCredential();
identityBuilder.AddInMemoryScopes(identitySrvConfig.GetScopes());
identityBuilder.AddInMemoryClients(identitySrvConfig.GetClients());
保护 API:
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = identityOptions.Authority,
ScopeName = "userProfile_api",
RequireHttpsMetadata = false
});
调查:
问题是承载未通过身份验证
Bearer was not authenticated. Failure message: IDX10501: Signature validation failed. Unable to match 'kid': 'e4f3534e5afd70ba74c245fe2e39c724', token
经过一番调查,似乎身份服务器正在生成一个导致签名验证失败的新密钥。
在日志中,我可以看到两个警告事件最终发生的时间,然后我看到“存储库不包含可行的默认密钥”和“应该向环中添加一个新密钥”
问题
即使我使用临时签名 (SetTemporarySigningCredential) 并且我没有重新启动服务器,为什么在密钥生命周期将近 3 个月的任何时候都没有密钥?
Creating key {a2fffa4a-345b-4f3b-bae7-454d567a1aee} with creation date 2017-03-03 19:15:28Z, activation date 2017-03-03 19:15:28Z, and expiration date 2017-06-01 19:15:28Z.
我该如何解决这个问题?
【问题讨论】:
-
获取真正的签名证书而不是临时证书 - 然后再次测试。
-
你是否也在重启 API 项目?我认为该中间件缓存了发现文档。我可能错了。
标签: jwt access-token identityserver4 thinktecture-ident-server