如何在单个ASP.NET Core应用程序中基于某些内容动态更改OpenID配置? [英] How to dynamically change OpenID configuration based on something in a single ASP.NET Core application?

查看:52
本文介绍了如何在单个ASP.NET Core应用程序中基于某些内容动态更改OpenID配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 Startup.cs ConfigureServices 中指定了一些OpenID配置:

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!

推荐答案

不要以为可以,但是如果要添加多个服务,可以这样做.客户.

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?

没有什么可以阻止您将OpenIdConnectHandler的源添加到您自己的应用程序,然后根据需要进行调整.它非常简单,我自己做了一下,以了解它的内部工作原理.

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.

来源在这里: https://github.com/dotnet/aspnetcore/tree/master/src/Security/Authentication/OpenIdConnect

这篇关于如何在单个ASP.NET Core应用程序中基于某些内容动态更改OpenID配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆