【发布时间】:2023-03-16 03:42:01
【问题描述】:
我们使用 IdentityServer4 来保护我们在 Azure 上的 ASPnetCore API。今天下午,我们遇到了一件非常奇怪的事情。
我们的一个 API 只是根据用户的子声明(例如用户 ID)从数据库表中返回所有项目。今天有两个用户报告说没有看到他们自己的物品。这段代码已经运行了好几年了。
我们的 startup.cs 包含以下内容:
services.AddStackExchangeRedisCache(action =>
{
action.Configuration = Configuration["RedisConnectionString"];
});
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = Configuration["identityServerUrl"];
options.ApiName = "<<redacted>>";
options.ApiSecret = "<<redacted>>";
options.EnableCaching = true;
options.CacheDuration = TimeSpan.FromMinutes(5);
});
由于 Redis 的超时问题,我们添加了以下行:
ThreadPool.SetMinThreads(300, 300);
这可能与用户 ID 被交换有关吗? 由于它是一个受保护的 API,所有请求都有一个承载令牌,该令牌在 Redis 中使用上述逻辑进行验证。 userid怎么会突然不一样了?
感谢您与我一起思考!
【问题讨论】:
标签: identityserver4 stackexchange.redis