【问题标题】:Can we set a static issuer in Identity Server 4?我们可以在 Identity Server 4 中设置静态颁发者吗?
【发布时间】:2018-01-16 19:17:21
【问题描述】:

响应中的访问令牌包含以下声明:

"alg": "RS256",
"kid": "143e829c2b57489969753ba4f8205979df0da988c640cffa5f1f4eda1b6e6aa4",
"typ": "JWT"
"nbf": 1481451903,
"exp": 1481455503,
"iss": "https://localhost:44350",
"aud": [ "https://localhost:44350/resources", "customAPI" ],
"client_id": "oauthClient",
"scope": [ "customAPI.read" ]

这是告诉我的应用程序使用 IdentityServer 进行身份验证的配置

app.UseIdentityServerAuthentication(
    new IdentityServerAuthenticationOptions
        {
            Authority = "https://localhost:44350/",
            ApiName = "customAPI",
            ApiSecret = "secret",
            AllowedScopes = {"customAPI.full_access", "customAPI.read_only" },                
            RequireHttpsMetadata = false
        });

如何允许用户在 IdentityServer 的不同别名上进行身份验证,除了 https://localhost:44350/ 例如:http://192.168.1.20:44350/

由于目前从后一个域获取的令牌在我的客户端上被视为无效,该客户端将权限设置为前一个域。

【问题讨论】:

    标签: authentication identityserver4


    【解决方案1】:

    您可以在ConfigureServices 方法中添加 IdentityServer 时设置静态颁发者名称。它在传递给 AddIdentityServer 的选项上。

    https://identityserver4.readthedocs.io/en/release/reference/options.html

    【讨论】:

    • 如果我需要根据每个客户进行更改?
    • 这必须是一个uri吗?非 uri 字符串会起作用吗?
    • 这个 IssuerUri 参数在逻辑上应该是一个 Uri,但实际上不是,因为它只是一个字符串,在令牌中显示为 'iss' 和生成的发现文档。我刚刚测试过这个。 IssuerUri = "foo" 和令牌一样出现在文档中,并且被接受。 (这对开发环境和内部 docker 网络来说是一个主要好处。)请注意,使用每个请求的 URL 可以让您查看在哪个域上完成了身份验证,并有助于使生产环境更加完善以这种方式确保安全。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-08
    • 2019-06-13
    • 1970-01-01
    • 2019-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多