【发布时间】:2016-12-18 13:22:01
【问题描述】:
生日快乐!
我没有看到太多这方面的内容,因为在撰写本文时它都是全新的。我正在尝试编写一个服务结构应用程序,在用户通过 ACS 进行身份验证后为 Web 应用程序 (html/js) 提供服务。我可以很容易地让它在非服务结构环境中与 OWIN 一起使用,即 IIS 后面的传统 Asp Net 应用程序。我正在尝试将令牌身份验证与 Azure 访问控制结合使用。
所以我现在使用服务结构改变了 OWIN 的工作方式这一事实是否与此有关?下面是我的 Service Fabric 应用程序的 Startup.cs 中的 OWIN ConfigureApp() 函数:
public static void ConfigureApp(IAppBuilder appBuilder)
{
appBuilder.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
appBuilder.UseCookieAuthentication(new CookieAuthenticationOptions());
appBuilder.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
Wtrealm = _realm,
MetadataAddress = _acsXmlMetaDataUrl
});
// Configure Web API for self-host.
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
appBuilder.UseWebApi(config);
}
注意我是如何在 Web api 中间件之前注入 WsFederation 中间件的,该中间件最终将用于为我的浏览器 html/js 应用程序提供服务。现在,当它启动并且我进行健全性测试(例如导航到 REST url)时,我的内容会立即提供,而不是被重定向到 Azure 访问控制以登录并获取身份验证令牌。在具有相同 OWIN 配置的传统 Asp Net 应用程序中,我确实在提供任何资源之前被重定向到 Azure 访问控制。
所以我的问题是如何将 WsFed 中间件注入 OWIN 管道,以便在服务结构上下文中工作?
任何帮助将不胜感激,感谢您的宝贵时间!
【问题讨论】:
标签: c# asp.net azure authentication ws-federation