动态设置 OWIN(按域) [英] Setup OWIN dynamically (by domain)

查看:19
本文介绍了动态设置 OWIN(按域)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试在我们使用 OWIN(包括 FB、谷歌、实时登录)的项目上设置一个白标.有没有办法动态设置他们的 API 凭据,比如如果他们更改域,设置就会更改.

We are trying to setup a white label on our project that uses OWIN(includes FB, google, Live logins). Is there a way to setup their API credential dynamically, say if they changes the domain the settings will change.

我认为 owin 比 MVC 更早加载?有没有办法在 Global.asax(Request) 上加载它?

I think owin loads earlier than MVC? Is there a way that we can load it on Global.asax(Request)?

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ConfigureAuth(app);
    }
}

更新:

换句话说,单个应用程序将托管许多域和子域(白标).

In other words a single Application will host many domains and sub domains(white labeling).

推荐答案

我今天一直在谷歌上搜索同样的东西.然后我在 http://aspnet.codeplex 找到了一个不错的 OWIN 示例.com/SourceControl/latest#Samples/Katana/BranchingPipelines/BranchingPipelines.sln 解释了 OWIN 的分支功能.如果我正确理解此示例,您应该能够根据请求参数(例如主机标头、cookie、路径或使用 app.Map() 或 app.MapWhen() 方法的任何内容)配置不同的 OWIN 堆栈.

I have been googling on the same things today. Then I found a nice OWIN sample at http://aspnet.codeplex.com/SourceControl/latest#Samples/Katana/BranchingPipelines/BranchingPipelines.sln that explained the branching capabilities of OWIN. If I understand this sample correctly, you should be able to configure different OWIN stacks depending on request parameters such as host header, cookie, path or whatever using the app.Map() or app.MapWhen() methods.

假设您有 2 个不同的 DNS 域,代表 2 个具有不同登录配置的客户,您可以根据主机标头的值初始化 OWIN 以使用不同的配置:

Let's say you have 2 different DNS domains representing 2 customers with different login configs, you can initialize OWIN to use different configs depending on the value of the host header:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {

        app.MapWhen(ctx => ctx.Request.Headers.Get("Host").Equals("customer1.cloudservice.net"), app2 =>
        {
            app2.UseWsFederationAuthentication(...);
        });
        app.MapWhen(ctx => ctx.Request.Headers.Get("Host").Equals("customer2.cloudservice.net"), app2 =>
        {
            app2.UseGoogleAuthentication(...);
        });
    }
}

这篇关于动态设置 OWIN(按域)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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