Here是我如何创建基于声明的授权属性。但我对这项工作有些怀疑。安全webapi与基于声明的有效智威汤逊
由于代码从我的启动类:
public void Configuration(IAppBuilder app)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = ConfigurationManager.AppSettings["Authentication:Authority"],
RequiredScopes = ConfigurationManager.AppSettings["Authentication:Scopes"].Split(' ').ToList(),
PreserveAccessToken = true
});
}
我期待,如果我有这样的属性我控制器和I发送一个无效的令牌(无效签名)的请求将被自动拒绝未经授权的,但是来自该属性的代码被执行。
不应该OWIN
首先验证令牌吗?
如何确保令牌有效(有效的狭窄,签名,未过期等),并且只有在验证了声明之后?
从你以前的问题:如果你改变返回语句'返回token.Claims.Any'与'返回token.Claims.All'你仍然得到这个错误? – Tinwor
@Tinwor这将要求所有令牌的声明是相同的,而不是仅仅检查它们中的任何一个是否匹配 –