gpt4 book ai didi

c# - 在新租户的 OwinStartup 之后添加 Owin 管道中间件

转载 作者:太空狗 更新时间:2023-10-29 22:26:10 24 4
gpt4 key购买 nike

我有一个 Multi-Tenancy 应用程序,其中每个租户都可以为 WsFed 或 OpenIdConnect 定义自己的 ClientID、权限等。所有租户都在 OwinStartup 中注册如下:

 public void Configuration(IAppBuilder app)
{
List<WsFederationAuthenticationOptions> WsFedTenantOptions = BuildWsFedTenantOptionsList();
List<OpenIdConnectAuthenticationOptions> OpenIdConnectTenantOptions = BuildOpenIdConnectTenantOptionsList();

app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions() { CookieSecure = CookieSecureOption.Never });

foreach (var WsFedTenantOption in WsFedTenantOptions)
app.UseWsFederationAuthentication(WsFedTenantOption);

foreach (var OpenIdConnectTenantOption in OpenIdConnectTenantOptions)
app.UseOpenIdConnectAuthentication(OpenIdConnectTenantOption);

...
}

它通过 context.Authentication.Challenge(AuthenticationType) 切换使用哪个 STS。这工作得很好。

问题是,当新租户注册时,我如何访问 IAppBuilder 并添加新的 AuthenticationOptions 而无需应用程序池回收?

最佳答案

IAppBuilder在Startup后不存在,用于构建请求执行管道然后被丢弃。管道未设计为在启动后进行修改。

关于c# - 在新租户的 OwinStartup 之后添加 Owin 管道中间件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28955118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com