asp.net-core - IdentityServer4 从 appsettings.json 读取客户端声明
问题描述
如何从 appsettings.json 文件中读取客户端声明?
我有这个 appsettings.json:
"IdentityServer": {
"Clients": [
{
"Enabled": true,
"ClientId": "client1",
"AlwaysSendClientClaims": true,
"Claims": [
{
"Type": "custom_claim1",
"Value": "value1"
},
{
"Type": "custom_claim2",
"Value": "value2"
}
]
}
]
}
而且,我像文档说的那样加载客户端配置:
var builder = services.AddIdentityServer(opts =>
{
/// Opts removed for simplicity
})
.AddInMemoryClients(Configuration.GetSection("IdentityServer:Clients"));
一切正常,除了客户要求。我在 Jwt.io 解码工具中看不到它们。
解决方案
由于无法从 json 反序列化 Claim 对象的当前实现,因此从 appSettings.json 绑定 Clients[] 中的 Claims 集合存在问题。
https://github.com/IdentityServer/IdentityServer4/issues/2573
和这里
推荐阅读
- wordpress - 在 wordpress 的小屏幕上添加不会折叠的二级菜单
- ruby - 将动态数据列附加到多个 CSV
- java - 无法实例化驱动程序类“com.mysql.cj.jdbc.Driver”:在 jboss 中部署 war 文件时
- javascript - 将变量分配给二维数组的索引
- c# - 如何使用网络流发送消息(c#)
- javascript - 如何在不输入完整比较的情况下添加无限变化的石头剪刀布
- reactjs - React 道具中的索引签名
- javascript - 如何将动态选项(函数())从 JSON 传递给 Highcharts?
- azure-devops - 在 Azure DevOps 中从个人帐户更改为组织帐户
- javascript - vuejs 开发服务器编译器卡在 49%