Is it possible to call an equivalent of AddClient in ClientCredentialsTokenManagementBuilder at runtime? #143
Unanswered
S-Tasker
asked this question in
Open Source
Replies: 1 comment 2 replies
|
All |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
We are in a situation where we wish to use the ClientCredentialsTokenManagementBuilder via AddClientCredentialsTokenManagement in a .Net 8 app.
However, our clients & secrets are configured in an Azure Key Vault.
The Key Vault content is not loaded into the application as a configuration source, but rather by use of a SecretClient, e.g:
When we build the application, the SecretClient is setup, grabs the relevant secrets, and adds them to the ClientCredentialsTokenManagementBuilder via AddClient. This is all done during the "build" portion of the application, when IServiceCollection is being built up via WebApplication.CreateBuilder(args).Build().
However, this poses problems for integration tests - we cannot mock out the SecretClient, as we can only reach it during ConfigureServices - which runs after the SecretClient has already been created, and the population of ClientCredentialsTokenManagementBuilder is done.
We would like to refactor this, so that we add clients to be managed at runtime instead - but do not see how that is possible. (we could then easily mock our SecretClient)
Is there a way to leverage the functionality offered here by configuring this library at runtime, rather than during application startup?
All reactions