在OwinStartup之后为新的租户添加Owin管道中间件 [英] Add Owin Pipeline Middleware after OwinStartup for new Tenant
问题描述
我有一个多租户应用程序,每个租户都可以为WsFed或OpenIdConnect定义自己的ClientID,授权等.所有租户都在OwinStartup中注册,如下所示:
I have a multi-tenant application where each tenant can define their own ClientID, Authority, etc for either WsFed or OpenIdConnect. All the tenants are registered in the OwinStartup as below:
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.这真的很好.
It switches which STS to use via context.Authentication.Challenge(AuthenticationType)
. This is working really well.
问题在于,当新的租户签约时,如何访问IAppBuilder
并添加新的AuthenticationOptions
而又不回收应用程序池?
The issue is that when a new tenant signs up, how do I access the IAppBuilder
and add the new AuthenticationOptions
without an Application Pool recycle?
推荐答案
启动后不存在IAppBuilder,它用于构建请求执行管道,然后丢弃.管道不适合在启动后进行修改.
IAppBuilder does not exist after Startup, it is used to build the request execution pipeline and then discarded. The pipeline was not designed to be modified after Startup.
这篇关于在OwinStartup之后为新的租户添加Owin管道中间件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!