【问题标题】:How to configure multiple Oidc providers in IdentityServer4如何在 IdentityServer4 中配置多个 Oidc 提供程序
【发布时间】:2019-08-02 18:43:22
【问题描述】:

我正在使用 IdentityServer 来处理外部身份验证和授权。为此我使用AddOpenIdConnect:

    .AddOpenIdConnect(oidcProviderOptions.AuthScheme, oidcProviderOptions.DisplayName, options =>
        {
            options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
            options.SignOutScheme = IdentityServerConstants.SignoutScheme;
            options.Authority = oidcProviderOptions.Uri;
            options.ClientId = oidcProviderOptions.ClientId;
            options.ResponseType = OpenIdConnectResponseType.IdToken;
            options.SaveTokens = true;
            if (oidcProviderOptions.AdditionalScopes != null) 
            {
                oidcProviderOptions.AdditionalScopes.ToList().ForEach(s => options.Scope.Ad);
            }
        });

    // preserve OIDC state in cache (solves problems with AAD and URL length)
        services.AddOidcStateDataFormatterCache(oidcProviderOptions.AuthScheme);

如果我使用不同的选项(天蓝色活动目录和 okta)两次调用此方法,我在连接时会收到 Invalid token 错误。上述配置是否有错误,或者这不是实现此功能的方法?

【问题讨论】:

    标签: asp.net-core identityserver4 openid-connect


    【解决方案1】:

    我怀疑这是因为每个人都需要定义不同的RemoteAuthenticationOptions.CallbackPath。如果它们共享相同的路径,则可能是“首先被调用获胜”的情况。例如:

    方案A:

    ...
    options.CallbackPath = "signin-oidc/a";
    ...
    

    架构 B:

    ...
    options.CallbackPath = "signin-oidc/b";
    ...
    

    【讨论】:

    • 还应指定options.SignoutCallbackPath
    猜你喜欢
    • 2021-09-28
    • 2014-07-03
    • 2017-08-07
    • 2022-01-16
    • 2020-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-15
    相关资源
    最近更新 更多