Configuring SamlConfigurations in Controller Level instead of Startup.cs

I’m loading the SamlConfigurations from the database and setting them up at the Startup.cs using services.Configure(config => ConfigureSaml(config)); method. But for my requirement this is kinda too early because there is a client application where we have provided the ability to configure the SamlConfiguration for each External IdP we have. And when these changes happen (eg. Changing the SignatureMethod to Sha512 from Sha256) then need to reflected immediately on the other side. Since the Startup.cs runs only once, these changes will not be used until the app restarts. can i move the logic to set the SamlConfigurations down to controller level where i can get the new changes from the database and use the updated configuration.

For dynamic configuration the setting of the SamlConfigurations may be performed at the controller level.
You probably still want to initialize the SamlConfigurations in Startup.cs as you’re currently doing.
Then, in the controller(s) where the configuration may be changed, update both SamlConfigurations and your database.
For example:

using ComponentSpace.Saml2;
using ComponentSpace.Saml2.Configuration;

public class ConfigurationController : Controller
{
private readonly SamlConfigurations _samlConfigurations;

public ConfigurationController(
SamlConfigurations samlConfigurations,
{
_samlConfigurations = samlConfigurations;
}
}

public async Task Update()
{
// Update the in-memory configuration.
_samlConfigurations.Configurations[0].GetPartnerIdentityProvider(“<a href=“http://ExampleIdentityProvider”)”>http://ExampleIdentityProvider")
.SignatureAlgorithm = SamlConstants.SignatureAlgorithms.RSA_SHA512;

// Update the database.
// Not shown.
}