Asp.net web api 使用Katana身份验证中间件保护WebAPI

Asp.net web api 使用Katana身份验证中间件保护WebAPI,asp.net-web-api,owin,Asp.net Web Api,Owin,我有一个WebAPI,它部署在Azure上带有Owin的WorkerRole中 我现在想尝试一下身份验证。(请记住,没有前端,因为我是工人角色) 我似乎找不到任何关于这个主题的例子或博客文章,我想知道这里是否有人做过任何事情,可以给我举一些例子 我一直在关注Microsoft.Owin.Security。*但我没有看到如何在我的Owin初创公司中使用它们的链接 我已经在启动中添加了以下内容: app.SetDefaultSignInAsAuthenticationType(CookieAuthe

我有一个WebAPI,它部署在Azure上带有Owin的WorkerRole中

我现在想尝试一下身份验证。(请记住,没有前端,因为我是工人角色)

我似乎找不到任何关于这个主题的例子或博客文章,我想知道这里是否有人做过任何事情,可以给我举一些例子

我一直在关注Microsoft.Owin.Security。*但我没有看到如何在我的Owin初创公司中使用它们的链接

我已经在启动中添加了以下内容:

app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.ExternalAuthenticationType);
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = CookieAuthenticationDefaults.ExternalAuthenticationType,
            AuthenticationMode = AuthenticationMode.Active,
            CookieName = CookieAuthenticationDefaults.CookiePrefix + CookieAuthenticationDefaults.ExternalAuthenticationType,
            ExpireTimeSpan = TimeSpan.FromMinutes(5),
        });
        app.UseMicrosoftAccountAuthentication( "hidden", "hidden");

我的下一步是什么?当我拥有前端时,如何进行身份验证。javascript或控制台应用程序中显示的示例就可以了。

Visual Studio 2013 RC附带的SPA模板将是一个很好的起点,通过删除所有MVC和ASP.NET相关代码,可以轻松地将其转换为OWIN自主机应用程序

请查看我的博客,以便更好地了解SPA模板中的安全功能


您最好使用承载令牌而不是cookie来保护您的web api。Cookie将容易受到攻击

看了一眼(本周忙碌的几天),它确实看起来像我要找的东西。谢谢。效果很好,我现在开始使用RTM版本。但是我的头撞在墙上,试图更新ApplicationAuthProvider。您是否可以提供更新版本的任何更改?(夜间建造并升级水疗中心)