IdentityServer4从appsettings.json阅读客户端声明

问题描述 投票:2回答:1

我如何从appsettings.json文件中读取客户要求?

我有这个appsettings.json:

"IdentityServer": {
     "Clients": [
       {
         "Enabled": true,
         "ClientId": "client1",
         "AlwaysSendClientClaims": true,
         "Claims": [
           {
             "Type": "custom_claim1",
             "Value": "value1"
           },
           {
             "Type": "custom_claim2",
             "Value": "value2"
           }
         ]
       }
     ]
}

并且,我加载客户端配置like the docs says

var builder = services.AddIdentityServer(opts =>
{
    /// Opts removed for simplicity
})
   .AddInMemoryClients(Configuration.GetSection("IdentityServer:Clients"));

除客户要求外,其他一切正常。我在Jwt.io解码工具中看不到它们。

asp.net-core identityserver4
1个回答
0
投票

由于无法从json反序列化Claim对象的当前实现,因此从appSettings.json绑定Clients中的Claims集合时出现问题[]。

https://github.com/IdentityServer/IdentityServer4/issues/2573

和这里

https://github.com/IdentityServer/IdentityServer4/pull/3887/files/ed14abc204960b2d5ca3418a868882a698e54d90

© www.soinside.com 2019 - 2024. All rights reserved.