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

标签 c# asp.net-mvc microservices identityserver4 audience

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

相关文章:

java - Docker 容器的跨源错误

c# - 从 Process.StandardOutput 捕获二进制输出

javascript - Asp.Net Mvc - ContentPlaceHolder- Javascript

transactions - 2PC vs Sagas(分布式事务)

docker - Web UI 代码和微服务在同一个 monorepo 中?

c# - 针对部署到多个环境的 Web 应用程序的 VS Application Insights

c# - 为什么 `String.Trim()` 不修剪对象本身?

c# - 平滑 3D 文件

c# - 将 block 与线程一起使用

c# - 身份验证超时后单击“注销”时出现找不到资源的错误