gpt4 book ai didi

c# - MVC 上的 IdentityServer : What is Audience refering in AddJwtBearer

转载 作者:行者123 更新时间:2023-12-02 22:12:23 24 4
gpt4 key购买 nike

我已经在我的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com