c# - 在 appsettings 中定义身份服务器客户端的未记录方式
问题描述
在探索身份服务器配置时,我发现了一个有趣的功能。这是根据官方文档在 appsettings.json 中定义客户端的方式:
{
"IdentityServer": {
"Clients": [
{
"ClientId": "TestClient1",
"RedirectUri": "/redirect",
"AccessTokenLifetime": 1800
},
{
"ClientId": "TestClient2",
"RedirectUri": "/redirect",
"AccessTokenLifetime": 1800
}
]
}
}
如您所见,预计将一个数组传递到 IdentityServer 配置的“客户端”属性中。
令人惊讶的是,以下代码也有效:
{
"IdentityServer": {
"Clients": {
"TestClient1": {
"Profile": "SPA",
"RedirectUri": "/redirect",
"AccessTokenLifetime": 1800
},
"TestClient2": {
"Profile": "SPA",
"RedirectUri": "/redirect",
"AccessTokenLifetime": 1800
}
}
}
}
它将一个对象传递给“客户端”属性。在这种情况下,子属性的名称(“TestClient1”、“TestClient2”)映射到 ClientId。RedirectUri 也可以正常工作,但会跳过其他属性(如 AccessTokenLifetime)。
那么,为什么它会起作用?我在哪里可以找到描述这种 IdentityServer 配置方式的文档?
解决方案
这在 IdentityServer 代码上并没有什么特别之处,这就是它没有记录的原因。这是读取配置的代码行。如您所见,它使用Config.Bind扩展。
推荐阅读
- swift - 如何使用 Realm 持久化来自依赖库的类中的实例
- python - 二维场的功率谱密度 - Python
- express - webpackDevMiddleware & webpackHotMiddleware 降低服务器速度
- c# - 跨项目继承测试方法
- json - 在 S3 上读取 Json 文件并在 LAMBDA 上返回
- php - laravel eloquent 如何使用多个“和”进行查询?
- testing - JMeter - 长时间均匀执行样本
- kubernetes - How to Enable KubeAPI server for HPA Autoscaling Metrics
- c++ - 将 Ceres 与带有 sse/avx 的库一起使用时出错
- xcode - 我无法在 CocoaPods 中进行“pod install”