【发布时间】:2021-05-23 08:07:24
【问题描述】:
我有 2 个独立的服务 - 一些 asp.net 核心服务(如果是 FooService,我们称之为)和安装了身份服务器 4 的安全服务(我们称之为 IdentityService)
在 FooService 上,我使用 Identity Server 4 AccessTokenValidation:
.AddIdentityServerAuthentication("IdentityService",
options =>
{
options.JwtValidationClockSkew = TimeSpan.Zero;
options.Authority = $"http://localhost:5000";
options.RequireHttpsMetadata = false;
options.SupportedTokens = SupportedTokens.Jwt;
});
启动后,如果 IdentityServer 关闭,则无法验证 JWT,因为它在地址 options.Authority = $"http://localhost:5000 上找不到 IdnetityServer4 端点 - 这是正常行为。
但是可能存在这样一种情况,当 IdentityServer 仍然处于运行状态时,它创建了 JWT,而 FooService 验证了其中的一些 - 然后 IdentityServer 关闭了 - FooService 仍然可以与这些尚未过期的 JWT 一起使用。此外,它成功验证了 valid 令牌,但它首先出现在请求中。就像,身份服务器 4 客户端缓存身份验证方案或 smth。
我尝试使用一些设置和参数:
options.SaveToken = false;
options.BackChannelTimeouts = TimeSpan.FromSeconds(1);
options.CacheDuration = TimeSpan.FromSeconds(1);
options.EnableCaching = false;
options.BackChannelTimeouts = TimeSpan.FromSeconds(1);
options.DiscoveryDocumentRefreshInterval = TimeSpan.FromMinutes(5);
但它仍然适用于 IdentityServer 关闭。
当 IdentityServer 关闭时,有什么方法可以停止验证 JWT?喜欢强制它使用授权 url 验证令牌吗?谢谢!
【问题讨论】:
标签: c# asp.net-core identityserver4