首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >.net核心客户端不会在受众中使用IdentityServer v3 -偏移量进行身份验证。

.net核心客户端不会在受众中使用IdentityServer v3 -偏移量进行身份验证。
EN

Stack Overflow用户
提问于 2017-03-08 11:25:40
回答 1查看 687关注 0票数 3

Given:

IdentityServer v3 JavaSCript客户端Asp核心Api客户端

JavaScript客户端使用标识服务器进行身份验证,并使用api的承载令牌发出请求。

api被配置为使用重新源所有者工作流。

问题:现在我得到:

观众:“http://localhost/identity/resources”。不匹配: validationParameters.ValidAudience:'MyApi‘或validationParameters.ValidAudiences:'null’

很明显观众的情况不匹配。我遗漏了什么?

Config

身份服务器中的ApiClient:

代码语言:javascript
运行
复制
 return new Client
            {
                Enabled = true,
                ClientId = "MyApi",
                ClientName = "The client for the Groupl Api",
                ClientSecrets = new List<Secret>
                {
                    new Secret("foo".Sha256())
                },
                Flow = Flows.ResourceOwner,
                AllowedScopes = ClientConstants.AllowedGrouplScopes()
            };

在要连接到标识服务器的api中:

代码语言:javascript
运行
复制
 JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();


        var authority = config["identity:authority:url"];
        app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
        {
            Authority = authority,
            RequireHttpsMetadata = false,
            EnableCaching = false,

            ApiName = "myApi", //Correct that this is the client id?
            ApiSecret = "foo"
        });

在这里,请求(Access_token省略)

代码语言:javascript
运行
复制
GET /api/values HTTP/1.1
Host: localhost:59364
Content-Type: application/json
Authorization: Bearer {access_token}

更新

当我设置LegacyAudienceValidation = true时,一切都很好,但是我不知道如何正确地处理这个问题?

EN

Stack Overflow用户

回答已采纳

发布于 2017-03-13 07:15:53

原因是身份验证行为发生了变化。IdentityServer 3不支持多个观众。Identityserver 4有。因此,对于旧的处理,LegacyAudienceValidation必须设置为true

票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42670034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档