You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which version of Duende IdentityServer are you using? 1.0.0
Which version of .NET are you using?
.NET 6
Describe the bug
When configuring the ClientCredentialsClient in ConfigureServices using services.Configure<ClientCredentialsClient>("client-name", _configuration.GetSection("config-section")), changes made in the configuration are not respected by the named ClientCredentialsClient IOptions instance. For instance, after locally updating a value in appsettings.json, I can see the updated value reflected in the IConfiguration instance, but this updated value is not propagated to the IOptions instance.
This IOptions instance is injected into the ClientCredentialsTokenEndpointService using the IOptionsSnapshot interface. The ClientCredentialsTokenEndpointService service has a Transient lifetime (added to the container using services.AddClientCredentialsTokenManagement()). The instance of the IOptionsSnapshot injected should have a Scoped lifetime; meaning that each new request should regenerate a given named IOptions instance, retrieving any updated values from the configuration provider. Regardless, the cached value of the IOptions instance is never updated.
The IOptions instance lifetime is as expected when injecting it using the IOptionsSnapshot interface in an MVC controller, i.e. an new given IOptions named instance is created, pulling config provider values, on every request.
The ClientCredentialsTokenHandler is added to my HttpClient using the AddClientCredentialsTokenHandler extension method, e.g:
After making a successful HttpClient call (i.e. OAuth token was retrieved successfully), change configuration value that the ClientCredentialsClient IOptions is bound to. This can be achieved by changing appsettings.json values locally.
Which version of Duende IdentityServer are you using?
1.0.0
Which version of .NET are you using?
.NET 6
Describe the bug
When configuring the ClientCredentialsClient in ConfigureServices using
services.Configure<ClientCredentialsClient>("client-name", _configuration.GetSection("config-section"))
, changes made in the configuration are not respected by the named ClientCredentialsClient IOptions instance. For instance, after locally updating a value in appsettings.json, I can see the updated value reflected in the IConfiguration instance, but this updated value is not propagated to the IOptions instance.This IOptions instance is injected into the ClientCredentialsTokenEndpointService using the IOptionsSnapshot interface. The ClientCredentialsTokenEndpointService service has a Transient lifetime (added to the container using
services.AddClientCredentialsTokenManagement()
). The instance of the IOptionsSnapshot injected should have a Scoped lifetime; meaning that each new request should regenerate a given named IOptions instance, retrieving any updated values from the configuration provider. Regardless, the cached value of the IOptions instance is never updated.The IOptions instance lifetime is as expected when injecting it using the IOptionsSnapshot interface in an MVC controller, i.e. an new given IOptions named instance is created, pulling config provider values, on every request.
The ClientCredentialsTokenHandler is added to my HttpClient using the AddClientCredentialsTokenHandler extension method, e.g:
To Reproduce
After making a successful HttpClient call (i.e. OAuth token was retrieved successfully), change configuration value that the ClientCredentialsClient IOptions is bound to. This can be achieved by changing appsettings.json values locally.
Expected behavior
IOptionsSnapshot instance receives updated configuration values.
Log output/exception with stacktrace
N/A
Additional context
I fixed this issue simply by changing the IOptions interface injected into ClientCredentialsTokenEndpointService from IOptionsSnapshot to IOptionsMonitor (ref: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-6.0#options-interfaces).
However, IOptionsSnapshot should work as intended here.
Changing:
to
The text was updated successfully, but these errors were encountered: