嗨,我正在尝试添加多个提供商
public static AuthenticationBuilder AddIdentityProviders(this AuthenticationBuilder builder, IConfiguration configuration)
{
var identityProvidersOptions = configuration.GetSection(identityProvidersSectionName)
.Get<IdentityProviderOptions[]>();
var ipFactory = new IdentityProviderControlFactory();
foreach (var identityProvider in identityProvidersOptions)
{
if ( Enum.TryParse(identityProvider.Discriminator, out IdentityProviderTypes accessControlType)
&& accessControlType != IdentityProviderTypes.None )
{
builder = ipFactory.GetIdentityProviderService(accessControlType)
.Register(builder, configuration, identityProvider);
}
else
{
throw new NotImplementedException();
}
}
return builder;
}
在设置中,我有两个提供程序,然后为每个“ register”方法分配了空白:
AuthenticationBuilder Register(AuthenticationBuilder builder, IConfiguration configuration, IdentityProviderOptions identityProviderOptions)
在里面创建一个像这样的单例:
builder.Services.AddSingleton<IConfigureOptions<OpenIdConnectOptions>, ConfigureAzureOptions>();
builder.AddOpenIdConnect(identityProviderOptions.Name, identityProviderOptions.Name, _ => { });
几秒钟之内
builder.Services.AddSingleton<IConfigureOptions<OpenIdConnectOptions>, ConfigureIBMOptions>();
builder.AddOpenIdConnect(identityProviderOptions.Name, identityProviderOptions.Name, _ => { });
这似乎是一个问题,因为似乎只能注册一个提供程序,而第二秒只能覆盖某些值,那么如何为身份服务器注册多个提供程序呢?
如果添加两个identityProviders,则会出现异常
System.Security.Cryptography.CryptographicException: 'The payload was invalid.'
答案 0 :(得分:0)
我知道这已经与CallbackPath和SignedOutCallbackPath有关,因为每个提供程序都必须有所不同,我现在正在寻找一种方法来覆盖这些终结点。
“您将在目标身份提供者中配置为允许站点的特定CallbackPath和SignedOutCallbackPath。因此,当目标身份提供者回发时,它将回发到您在CallbackPath中配置的路由,并且Oidc中间件将选择正确的配置“