问题
We have some OpenID configuration specified in ConfigureServices
in Startup.cs
:
services.AddOpenIdConnect("something", "Something", options =>
{
// ... //
});
How can we change the configuration we've outlined here dynamically, on a per request basis, based on certain rules?
Can this be done in a middleware? If so, please give an example, thank you!
回答1:
Don't think you can do that, but you can if you want add multiple services.AddOpenIdConnect(...) handlers and use a different one for different clients.
What kind of usecase do you have? What do you try to create?
There's nothing stopping you from adding the source of the OpenIdConnectHandler to your own application and then tweaking it to your needs. Its pretty simple and I have done that myself to learn the inner workings of it.
The source is here: https://github.com/dotnet/aspnetcore/tree/master/src/Security/Authentication/OpenIdConnect
来源:https://stackoverflow.com/questions/64242848/how-to-dynamically-change-openid-configuration-based-on-something-in-a-single-as