Add Owin Pipeline Middleware after OwinStartup for new Tenant

随声附和 提交于 2019-12-06 03:30:47

问题


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);

    ...
}

It switches which STS to use via context.Authentication.Challenge(AuthenticationType). This is working really well.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/28955118/add-owin-pipeline-middleware-after-owinstartup-for-new-tenant

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