How to change IdentityServer OIDC discovery endpoint base url?

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

IdentityServer4 提供了一个 OIDC 发现端点,可用于检索有关授权服务器的元数据,包括令牌端点。发现端点可通过 /.well-known/openid-configuration relative to the base address of your Token Server。例如,如果我们在本地运行应用程序并向以下端点执行 GET 请求:

https://localhost:44354/.well-known/openid-configuration

然后我们将看到以下 JSON 模式:

{
    "issuer": "https://localhost:44354",
    "jwks_uri": "https://localhost:44354/.well-known/openid-configuration/jwks",
    "authorization_endpoint": "https://localhost:44354/connect/authorize",
    "token_endpoint": "https://localhost:44354/connect/token",
    "userinfo_endpoint": "https://localhost:44354/connect/userinfo",
    "end_session_endpoint": "https://localhost:44354/connect/endsession",
    
    // code omitted for brevity
}

基于“发现端点可通过 /.well-known/openid-configuration relative to the base address of your Token Server”条款,我想知道如何更改此端点的基地址。在 ASP.NET Core 应用程序中有可能吗?

c# asp.net-core .net-core identityserver4 openid-connect
2个回答
0
投票

这个好像改不了了

如果你查看源代码here,你会发现它是一个常量:

但是,这个 GitHub 问题及其链接到的问题可能会给您一些替代方案:

如何自定义路线路径?


0
投票

不会帮助行动,但对其他人...

我不确定这是一种记录在案的方法,但这有效(放置before UseIdentityServer):

    app.Use(async (ctx, next) =>
    {
        var serverUrls = ctx.RequestServices.GetRequiredService<IServerUrls>();
        serverUrls.Origin = serverUrls.Origin = "https://yourneworigin;
        await next();
    });

    app.UseIdentityServer();

在正确配置我们的反向代理之前,我将其用作临时解决方法。

对于那些因为反向代理问题而来到这里的人,Duende 有这个文档: https://docs.duendesoftware.com/identityserver/v6/deployment/proxies/

注意几个重要方面:

  • 使用 UseForwardedHeaders 需要在管道的开始
  • 反向代理需要配置发送“forwarded for”标头
© www.soinside.com 2019 - 2024. All rights reserved.