How to dynamically change OpenID configuration based on something in a single ASP.NET Core application?

青春壹個敷衍的年華 提交于 2021-01-29 10:02:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!