Closed aurecchia closed 3 weeks ago
It looks like our code does not work that well with a custom configuration context.
For now, you can add a workaround by registering your own implementation class with the ConfigurationDbContext service registration:
services.AddScoped<ConfigurationDbContext>(svcs =>
svcs.GetRequiredService<MyDerivedConfigurationDbContext>());
This need to be done after the call to AddConfigurationStore
, because it need to overwrite the built in service registration.
Hi folks š
Which version of Duende IdentityServer are you using?
7.0.7
Which version of .NET are you using?
SDK 8.0.300
Describe the bug
Not exactly a bug, more an inconvenience. We added the configuration API to our instance of IdentityServer (shared host setup), and we had dependency injection issues with the
ClientConfigurationStore
.We have a custom implementation of
ConfigurationDbContext
that inherits from the Duende one to customize theOnModelCreatingMethod
. Our custom type is registered in DI instead of the built-in one. TheClientConfigurationStore
depends on the concrete type from Duende. This means that we cannot just call.AddClientConfigurationStore()
like shown in the documentation, but have to provide our own implementation of theClientConfigurationStore
.Is there a reason why the dependency is on the
ConfigurationDbContext
class instead of theIConfigurationDbContext
interface?I wanted to understand if this was done deliberately before opening a PR.
To Reproduce
ConfigurationDbContext
and register the custom implementationClientConfigurationStore
using.AddClientConfigurationStore()
An error will be thrown when the
ClientConfigurationStore
is first instantiated or when DI scope validation runs.Expected behavior
It should be possible to use the built-in
ClientConfigurationStore
with customConfigurationDbContext
and using the provided configuration extensions.Let me know if you require additional details or I can help in any other way.