jwt - Identityserver 4 API令牌验证自省端点不起作用
问题描述
我对 identityserver4 验证模式有一些疑问。我已经用Local和ValidationEndpoint测试了这些是我发现 我的 API 在 .net Framework 4.6中的区别
配置
var IDSBearerOption = new IdentityServerBearerTokenAuthenticationOptions
{
AuthenticationType = "Bearer",
Authority = "https://localhost:5001",
RequiredScopes = new[] { "api1" },
PreserveAccessToken = true,
RoleClaimType = "role",
ValidationMode = ValidationMode.Local,
ClientId = "TestAPI1", // Value on ApiResource
ClientSecret = "secret", // Value on ApiResource TestAPI1's APIsecret
};
app.UseAuthorization(opt =>
{
opt.AddPolicy("adminusers", policy =>
{
policy.RequireAuthenticatedUser();
policy.RequireClaim("role", "admin"); //Also value can be checked like this
});
});
控制器
[Authorize]
[RoutePrefix("api")]
public class ValuesController : ApiController
{
[Route("values")]
[ResourceAuthorize(Policy = "adminusers")]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
邮差
工作正常。
提琴手
如果我将 ValidationMode 更改为 ValidationEndpoint 我会遇到问题 Postman
提琴手
身份服务器日志
查询
- ValidationEndpoint 和 Local 之间的区别?
- 何时使用 ValidationEndpoint ?
- 为什么 ValidationEndpoint 不起作用,为什么会出现 403 错误,如何解决这个问题?
- 假设验证发生在自省端点,为什么提琴手在使用“ValidationEndpoint”时没有记录流量?
解决方案
推荐阅读
- php - 将任意属性附加到 Blade x 组件,绑定属性à la Vue.js
- r - 如果在字符向量元素中找不到正则表达式匹配,如何返回 NULL?
- ios - 如果一个发布者没有产生任何值,如何让 CombineLatest3 返回结果?
- android - 为什么 Android Studio 中的 Image Asset 工具不会为 xxxhdpi 文件夹生成 PNG 文件?
- uwp - 如何使用 Windows Cloud Sync Engine API 支持删除?
- java - 需要从使用 java 3.12.0 驱动程序的 java 应用程序中的 mongoDB Atlas 中获取具有相同 first_name 的客户的 customerID 列表
- python - 为什么我的表单没有保存到管理数据库?
- python - 没有响应和程序冻结
- javascript - 无论值如何,如何从选择器中排除具有属性的元素
- c# - 清理验证码图像,然后使用 Tesseract OCR (.NET)