I am using ComponentSpace SAML2 SSO Nuget package for ASP.net core in my ASP.net core web application where i need to have multiple SAML configurations to support different clients with different SAML configurations. I am loading the SAML Configurations from a database table and I am populating the samlConfigurations.Configurations property with the list of SamlConfigurations. For each SAMLConfiguration, i am setting the ID from the database table as the ID of the SAML Configuration so that i can set which SAML Configuration to use for each user that is trying to login.
I have SingleSignOn() method in my AccountController that would initiate the Sso. just before initiating the SSO i am setting the Saml Configuratin Id using the SetConfigurationIDAsync() method. The code looks like this.
public async Task<IActionResult> SingleSignOn(Operator oper)
{
int samlIdpConfigId;
if (oper.SamlIdpConfigId != null)
{
samlIdpConfigId = (int) oper.SamlIdpConfigId;
}
else
{
samlIdpConfigId = oper.MasterEngagement.SamlIdpConfigId ?? -1;
}
if (samlIdpConfigId < 0)
{
throw new SecurityException("Invalid SamlIdpConfigId found");
}
await _samlServiceProvider.SetConfigurationIDAsync(samlIdpConfigId.ToString());
var partnetName = _configuration.GetValue<string>(Constants.AppSetting.PartnerName);
await _samlServiceProvider.InitiateSsoAsync(partnetName);
return new EmptyResult();
}
The problem is the Configuration ID does not seem to be set properly. In the ASP.net core logs that are generated i see the following lines form the ComponentSpace library.
fail: ComponentSpace.Saml2.SamlServiceProvider[100]
Initiation of SSO to the partner identity provider
http://MockIdentityProvider has failed.
ComponentSpace.Saml2.Exceptions.SamlConfigurationException: Multiple SAML configurations exist but a configuration ID hasn't been specified.
at ComponentSpace.Saml2.Configuration.SamlConfigurations.GetConfiguration(String configurationID)
at ComponentSpace.Saml2.SamlProvider.GetSamlConfiguration()
at ComponentSpace.Saml2.SamlServiceProvider.<InitiateSsoAsync>d__5.MoveNext()
fail: ComponentSpace.Saml2.SamlServiceProvider[100]
Initiation of SSO to the partner identity provider
http://MockIdentityProvider has failed.
ComponentSpace.Saml2.Exceptions.SamlConfigurationException: Multiple SAML configurations exist but a configuration ID hasn't been specified.
at ComponentSpace.Saml2.Configuration.SamlConfigurations.GetConfiguration(String configurationID)
at ComponentSpace.Saml2.SamlProvider.GetSamlConfiguration()
at ComponentSpace.Saml2.SamlServiceProvider.<InitiateSsoAsync>d__5.MoveNext()
I can not find any examples or material on how to fix this or how to do this properly if i am doing something wrong. Some help would be much appreciated