Multiple config error

Hi,
I’m not understanding why the exception since everything is named, can I get a little help here?

I’m creating 2 configurations programmatically on app startup:

private void ConfigureSaml(SamlConfigurations samlConf)
{
string certPath = @“Certificates\idp.pfx”;
string certPass = “password”;

samlConf.Configurations = new List()
{
new()
{
Id = 2,
Name = “NAMEA”,
LocalIdentityProviderConfiguration = new LocalIdentityProviderConfiguration()
{Id = 2,

Name = “NAMEB”,
Description = “Description”,
LocalCertificates = new List()
{
new()
{
FileName = @“AppData\Certificates\idp.pfx”,
Password = certPass
}
},
},
PartnerServiceProviderConfigurations = new List()
{
new()
{
Name = “NameC”,
Description = “Description”,
WantAuthnRequestSigned = true,
SignSamlResponse = true,
SignAssertion = true,
EncryptAssertion = true,
AssertionConsumerServiceUrl = "<a href=“https://company.com/SAML/AssertionConsumerService",">https://company.com/SAML/AssertionConsumerService”,
PartnerCertificates = new List()
{
new()
{
FileName = @“AppData\Certificates\cert-dev.20230808.pem”,
Password = certPass
}
}
}
}
},

new()
{
Id = 1,
Name = “NameD”,
LocalIdentityProviderConfiguration = new LocalIdentityProviderConfiguration()
{Id = 1,
Name = “NAMEE”,
Description = “Description”,
LocalCertificates = new List()
{
new()
{
FileName = @“AppData\Certificates\idp.pfx”,
Password = certPass
}
},
},
PartnerServiceProviderConfigurations = new List()
{
new()
{
Name = “NAMEF”,
Description = “Description”,
WantAuthnRequestSigned = true,
SignSamlResponse = false,
SignAssertion = true,
EncryptAssertion = true,
AssertionConsumerServiceUrl = "<a href=“https://conpany.com/SAML/AssertionConsumerService",">https://conpany.com/SAML/AssertionConsumerService”,
PartnerCertificates = new List()
{
new()
{
FileName = @“AppData\Certificates\cert-dev.20230808.pem”,
Password = certPass
}
}
}
}
},
};
}



Then on the controller, I call

await _samlIdentityProvider.InitiateSsoAsync(partnerName, nameId, attributes, relayState);

And then I get the following exception:

An unhandled exception has occurred while executing the request.
ComponentSpace.Saml2.Exceptions.SamlConfigurationException: Multiple SAML configurations exist but a configuration name hasn’t been specified.
at ComponentSpace.Saml2.Configuration.Resolver.SamlConfigurationResolver.GetConfiguration(String configurationName)
at ComponentSpace.Saml2.Configuration.Resolver.SamlConfigurationResolver.GetLocalIdentityProviderConfigurationAsync(String configurationName)
at ComponentSpace.Saml2.SamlIdentityProvider.GetLocalIdpConfigurationAsync()
at ComponentSpace.Saml2.SamlIdentityProvider.InitiateSsoAsync(String partnerName, String userID, IList attributes, String relayState, String authnContext)
at Company.FakeIdp.netCore.Controllers.SamlController.Orion(String spEndpoint, String nameId, String householdId, String token) in C:\src\Company\src\Company.FakeIdp.netCore\Controllers\IdpController.cs:line 298

As you have specified two SAML configurations (NAMEA and NAMED), we need to know which SAML configuration to use when processing the _samlIdentityProvider.InitiateSsoAsync request.

This is done by calling _samlIdentityProvider.SetConfigurationNameAsync.

For example:

await _samlIdentityProvider.SetConfigurationNameAsync(“NAMEA”);
await _samlIdentityProvider.InitiateSsoAsync(partnerName, nameId, attributes, relayState);

Note that multiple SAML configurations typically are used in multi-tenancy applications. Most applications only require a single SAML configuration.

Also, the Id property is there in support of storing SAML configurations in the Entity Framework. It’s recommended you don’t set this property.

For more information, please refer to our Configuration Guide.