ComponentSpace

Forums



Accessing database from within GetLocalServiceProviderConfigurationAsync(string configurationID)


Accessing database from within...

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

Group: Awaiting Activation
Posts: 5, Visits: 37
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 (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K
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 (13 reputation)New Member (13 reputation)New Member (13 reputation)New Member (13 reputation)New Member (13 reputation)New Member (13 reputation)New Member (13 reputation)New Member (13 reputation)New Member (13 reputation)

Group: Awaiting Activation
Posts: 5, Visits: 37
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 (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K
You're very welcome!

Regards
ComponentSpace Development
GO


Similar Topics


Execution: 0.000. 1 query. Compression Enabled.
Login
Existing Account
Email Address:


Password:


Select a Forum....












Forums, Documentation & Knowledge Base - ComponentSpace


Search