0条评论
还没有人评论过~
参考 IdentityServer 的帮助文档 Protecting APIs ,在一个 .NERT 5.0 项目的 Startup 中添加了下面的代码
services.AddAuthentication("token")
// JWT tokens
.AddJwtBearer("token", options =>
{
options.Authority = Constants.Authority;
options.Audience = "resource1";
options.TokenValidationParameters.ValidTypes = new[] { "at+jwt" };
// if token does not contain a dot, it is a reference token
options.ForwardDefaultSelector = Selector.ForwardReferenceToken("introspection");
})
// reference tokens
.AddOAuth2Introspection("introspection", options =>
{
options.Authority = Constants.Authority;
options.ClientId = "resource1";
options.ClientSecret = "secret";
});
提示下面的错误
The name 'Selector' does not exist in the current context
请问需要安装哪个 nuget 包?
The Selector.ForwardReferenceToken is a little helper that I packaged up in the IdentityModel.AspNetCore.AccessTokenValidation nuget package.
https://leastprivilege.com/2020/07/06/flexible-access-token-validation-in-asp-net-core/