天儿真好!
我在这方面没有看到太多,因为在写这篇文章时它非常新颖.我正在尝试编写一个服务结构应用程序,在用户通过ACS进行身份验证后,它将为Web应用程序(html/js)提供服务.我可以轻松地在非服务结构环境中使用OWIN,即IIS后面的传统Asp Net应用程序.我正在尝试使用Azure Access Control进行令牌身份验证.
那么与我现在使用服务结构的事实有什么关系改变了OWIN的工作方式?下面是我的服务结构应用程序中的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);
}
Run Code Online (Sandbox Code Playgroud)
请注意我是如何在最终用于为我的浏览器html/js应用程序提供服务的web api 中间件之前注入WsFederation中间件的.现在,当这个启动并且我进行健全性测试时,例如导航到REST URL,我的内容会立即提供,而不是重定向到Azure Access Control以登录并获取身份验证令牌.在我使用相同OWIN配置的传统Asp Net应用程序中,我确实在提供任何资源之前将其重定向到Azure Access Control.
所以我的问题是如何将WsFed中间件注入OWIN管道,以便在服务结构上下文中工作?
非常感谢任何帮助,谢谢你的时间!