我已经在我的 API 网关中拥有可与我的应用程序配合使用的访问 token 。
var identityUrl = Configuration.GetValue<string>("urls:identity");
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(options =>
{
options.Authority = Configuration.GetValue<string>("IdentityUrlExternal");
options.RequireHttpsMetadata = false;
options.Audience = "api1";
options.Events = new JwtBearerEvents()
AddJwtBearer
中的受众选项指的是什么?这是指 ClientId
还是 ApiScope
?目前,我是根据我的移动应用程序设置的范围来与 API 网关进行通信的。如果我改变一些东西,例如从移动设备发送的客户端 ID (ro.client
),授权的 API 函数将无法访问它。
我想清楚地了解我的设置是否正确。
另外,如何在controller下的ASP.net MVC core项目中添加Authorized Scope?
最佳答案
以下链接将带您查看说明: http://docs.identityserver.io/en/latest/topics/apis.html
The ApiName property checks if the token has a matching audience (or short aud) claim.
In IdentityServer you can also sub-divide APIs into multiple scopes. If you need that granularity you can use the ASP.NET Core authorization policy system to check for scopes.
关于c# - MVC 上的 IdentityServer : What is Audience refering in AddJwtBearer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51622666/