【发布时间】:2014-10-13 03:11:41
【问题描述】:
我有一个多租户应用程序。每个租户都可以通过 Facebook、Twitter、Google 等使用 OAUTH-2 对其用户进行身份验证。每个租户都有自己的 API 密钥用于上述服务。
设置 OWIN 管道的典型方法是在 Startup 中“使用”身份验证提供程序,但这会在应用启动时设置 API 密钥。我需要能够为每个请求更改每个 oauth API 使用的密钥。
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
Provider = cookieAuthProvider,
CookieName = "VarsityAuth",
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseMicrosoftAccountAuthentication(
clientId: "lkjhlkjkl",
clientSecret: "kjhjkk");
我需要能够根据租户的每个请求更改这些设置。我该怎么做?
【问题讨论】:
-
到目前为止,我遇到了障碍。似乎 AuthenticationOptions 的典型实现(例如 FacebookAuthenticationOptions)被标记为内部,并且 Facebook auth 中间件使用 FacebookAuthenticationOptions(而不是接口)。因此,不可能覆盖 FacebookAuthenticationOptions 的 AppId 和 AppSecret 属性,因此我不得不推出自己几乎相同版本的 Facebook Auth 中间件。 :((悲伤的熊猫)
-
你好,我刚刚问了一个类似的问题,我需要根据租户是谁使用多个 OpenIdConnect 配置。如果您可以分享一些有关如何处理此问题的代码 sn-ps,那就太棒了!供您参考,是我的问题:stackoverflow.com/questions/25417620/…
-
您好 kingdangoless,请分享您的解决方案。社区将永远感激不尽。
标签: oauth-2.0 asp.net-mvc-5 owin owin-middleware