我正在尝试将IdentityServer4设置为使用多个外部IdP,这些IdP是在IAuthenticationSchemeProvider的AddScheme方法的帮助下动态添加的。
我已经成功地为OpenIdConnect IdP完成了这项工作,但在基于Saml2p的IdP上遇到了一些问题。在this示例中,我遵循了Saml2p的相同逻辑:
注入的IOptionsMonitorCache<Saml2pAuthenticationOptions>和:
if (await _schemeProvider.GetSchemeAsync(scheme) == null)
{
_schemeProvider.AddScheme(new AuthenticationScheme(scheme, scheme, typeof(Saml2pAuthenticationHandler)));
}
else
{
_saml2pOptionsCache.TryRemove(scheme);
}
_saml2pOptionsCache.TryAdd(scheme, samlOptions);我得到了一个例外:
Unable to resolve service for type 'Rsk.AspNetCore.Authentication.Saml2p.Factories.ISamlFactory``1[IdentityServer4.Saml.Generators.Interfaces.IServiceProviderMetadataGenerator]' while attempting to activate 'Rsk.AspNetCore.Authentication.Saml2p.Saml2pAuthenticationHandler'.
我不确定我是否应该在添加方案时设置一些关于Saml的额外配置,感谢任何帮助。
编辑:我正在为SAML2.0使用Rsk NuGet
发布于 2019-04-12 17:40:58
对AddSaml2p的调用注册了大量依赖项和身份验证处理程序。
我会在代码中的某个地方调用AddSaml2p,或者自己注册所需的依赖项,如下所示:
builder.Services.AddMemoryCache();
builder.Services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.TryAddScoped<ISamlFactory<IServiceProviderMetadataGenerator>,
builder.Services.TryAddScoped<ISamlFactory<ISaml2SingleSignOnRequestGenerator>, Saml2SingleSignOnRequestGeneratorFactory>();
builder.Services.TryAddScoped<ISamlFactory<ISaml2SingleLogoutRequestGenerator>, Saml2SingleLogoutRequestGeneratorFactory>();
builder.Services.TryAddScoped<ISamlFactory<ISaml2SingleSignOnResponseValidator>, Saml2SingleSignOnResponseValidatorFactory>();
builder.Services.TryAddScoped<ISamlBindingService, SamlBindingService>();
builder.Services.TryAddScoped<ISamlSigningService, SamlSigningService>();
builder.Services.TryAddScoped<IDateTimeService, SystemClockDateTimeService>();
builder.Services.TryAddScoped<ISamlTimeComparer, SamlTimeComparer>();
builder.Services.TryAddScoped<ISamlCorrelationStore, CookieCorrelationStore>();https://stackoverflow.com/questions/55642222
复制相似问题