ComponentSpace

Forums



Accessing database from within GetLocalServiceProviderConfigurationAsync(string configurationID)


Accessing database from within...

Author
Message
xnetdude
xnetdude
New Member
New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)

Group: Awaiting Activation
Posts: 4, Visits: 28
Hi,
This isnt strictly a Componentspace question, but it's a requirement so we can use the dynamic config from the database.

We are implementing the CustomConfigurationResolver and need to access our SQL Server database from within this method, which resides in the startup.cs class.

public override Task<LocalServiceProviderConfiguration> GetLocalServiceProviderConfigurationAsync(string configurationID)


The problem is we can't work out how to access our databse (DBContext) in this method as it's usually injected via DI after being configured in the ConfigureServices method in the same class, but it's not available in startup.cs (where the custom resolver code resides) outside of the ConfigureServices or Configure methods.

Once we solve that, our plan is to retrieve the corresponding IdP and SP config information using the configurationId from the database so they can be used during the asp.net core ChallengeResult call for SSO.

Thanks for any help in advance.





ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)

Group: Administrators
Posts: 2.8K, Visits: 8.6K
I recommend placing your CustomConfigurationResolver in a separate file. We included our example in the Startup file as it is relatively small and we wanted to ensure people saw this option.

You can use DI to inject your DbContext into the CustomConfigurationResolver. For example:


public CustomConfigurationResolver(YourDbContext dbContext)
{
  _dbContext = dbContext;
}



Please note that the configurationID supports multiple SAML configurations. Typically this is used in multi-tenancy environments. For more information, please refer to the Configuration Guide.

https://www.componentspace.com/Forums/8234/Configuration-Guide


Regards
ComponentSpace Development
xnetdude
xnetdude
New Member
New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)New Member (11 reputation)

Group: Awaiting Activation
Posts: 4, Visits: 28
ComponentSpace - 8/3/2021
I recommend placing your CustomConfigurationResolver in a separate file. We included our example in the Startup file as it is relatively small and we wanted to ensure people saw this option.

You can use DI to inject your DbContext into the CustomConfigurationResolver. For example:


public CustomConfigurationResolver(YourDbContext dbContext)
{
  _dbContext = dbContext;
}



Please note that the configurationID supports multiple SAML configurations. Typically this is used in multi-tenancy environments. For more information, please refer to the Configuration Guide.

https://www.componentspace.com/Forums/8234/Configuration-Guide

Sometimes you can't see the wood from the trees!
Thank you so much - 5* service as usual!



ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)ComponentSpace Development (3.9K reputation)

Group: Administrators
Posts: 2.8K, Visits: 8.6K
You're very welcome!

Regards
ComponentSpace Development
GO


Similar Topics


Execution: 0.000. 4 queries. Compression Enabled.
Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....









Forums, Documentation & Knowledge Base - ComponentSpace


Search