簡體   English   中英

abp 框架中的 OpenIddict - 在容器化環境中部署 (k8s)

[英]OpenIddict in abp framework - deploy in containerized environment (k8s)

abp 版本 6.0,分層(.Web,.HttpApi.Host,.AuthServer),MVC。

以下消息出現在.AuthServer 中。

客戶端驗證失敗,因為“https://webpage_url/signin-oidc”不是 AppName_Web 的有效 redirect_uri。 授權請求被拒絕,因為 redirect_uri 無效:“https://webpage_url/signin-oidc”。

如何正確設置 appsettings.json in.Web、.HttpApi.Host、.Web 和 .DbMigrator 項目以部署到容器化環境中? 應該在哪里為 auth 服務器設置內部 (k8s) url 地址,何時設置外部 url(可通過 inte.net 訪問)。

log中的Url https://webpage_url/signin-oidc為外部地址(可通過inte.net訪問)。

更改應用程序設置.json

客戶端驗證失敗,因為“https://webpage_url/signin-oidc”不是 AppName_Web 的有效 redirect_uri。 授權請求被拒絕,因為 redirect_uri 無效:“https://webpage_url/signin-oidc”。

可能您的重定向 uri 沒有播種,如果為該客戶端(應用程序)正確添加了重定向 uri,您可以檢查您的數據庫。

如何正確設置 appsettings.json in.Web、.HttpApi.Host、.Web 和 .DbMigrator 項目以部署到容器化環境中? 應該在哪里為 auth 服務器設置內部 (k8s) url 地址,何時設置外部 url(可通過 inte.net 訪問)。

log中的Url https://webpage_url/signin-oidc為外部地址(可通過inte.net訪問)。

不會根據您的部署環境更改重定向 uri 它應該指向 openid-provider 在登錄后重定向到的有效可達端點。

據我了解,除了正常的登錄流程外,您在與 isolated.network(k8s、docker)中的 openid-provider 交互時遇到問題。

由於您在真實域端點(如https://my-authserver.com )上有 auth-server ,因此您從試圖到達域的容器中收到錯誤( https://my-authserver.com/.well-known /openid-configuration ) 並且您收到 SSL 錯誤或未找到錯誤。

因此,您希望對內部容器完成內部請求(如 http://my-auth-container/.well-known/openid-configuration),而用戶交互的登錄/注銷應該使用公共域名( https:// )完成我的授權服務器.com )。

您可以根據您的部署添加OpenIdConnectOptions以將MetadataAddress配置為:

context.Services.Configure<OpenIdConnectOptions>("oidc", options =>
{
    options.MetadataAddress = configuration["AuthServer:MetaAddress"].EnsureEndsWith('/') +
                              ".well-known/openid-configuration";

    var previousOnRedirectToIdentityProvider = options.Events.OnRedirectToIdentityProvider;
    options.Events.OnRedirectToIdentityProvider = async ctx =>
    {
        // Intercept the redirection so the browser navigates to the right URL in your host
        ctx.ProtocolMessage.IssuerAddress = configuration["AuthServer:Authority"].EnsureEndsWith('/') +
                                            "connect/authorize";

        if (previousOnRedirectToIdentityProvider != null)
        {
            await previousOnRedirectToIdentityProvider(ctx);
        }
    };

var previousOnRedirectToIdentityProviderForSignOut =
    options.Events.OnRedirectToIdentityProviderForSignOut;

options.Events.OnRedirectToIdentityProviderForSignOut = async ctx =>
{
    // Intercept the redirection for signout so the browser navigates to the right URL in your host
    ctx.ProtocolMessage.IssuerAddress = configuration["AuthServer:Authority"].EnsureEndsWith('/') +
                                        "connect/endsession";

    if (previousOnRedirectToIdentityProviderForSignOut != null)
    {
        await previousOnRedirectToIdentityProviderForSignOut(ctx);
    }
};

這樣,登錄/注銷請求將被重定向到應該是公共域的configuration["AuthServer:Authority"] (如https://my-authserver.com ),內部請求將被重定向到configuration["AuthServer:MetaAddress"]應該是一個內部服務(比如 http://my-auth-container)

有關詳細信息,請查看:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM