e.g。
var OAuthServerOptions = new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(30),
Provider = container.Resolve(),
RefreshTokenProvider = container.Resolve()
};
// Token Generation
app.UseOAuthAuthorizationServer(OAuthServerOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
如何在asp.net 5(vnext)中执行此操作。
的引用:
http://www.asp.net/aspnet/overview/owin-and-katana/owin-oauth-20-authorization-server http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/ http://aspnetguru.com/adding-authentication-to-asp-net-web-api/ http://blogs.msdn.com/b/webdev/archive/2013/09/20/understanding-security-features-in-spa-template.aspx http://odetocode.com/blogs/scott/archive/2015/01/15/using-json-web-tokens-with-katana-and-webapi.aspx
答案 0 :(得分:0)
Microsoft决定不将OWIN OAuth授权服务器中间件迁移到ASP.NET 5,所以我自己完成了。您可以在以下GitHub repo https://github.com/XacronDevelopment/oauth-aspnet中找到源代码,也可以在ASP.NET 5项目中使用NuGet包OAuth.AspNet.AuthServer和OAuth.AspNet.Tokens。请参阅GitHub仓库中的示例,了解如何连接。
请注意,此端口的当前版本仅支持ASP.NET 5 Beta 7。将在几天内添加对Beta 8夜间版本的支持,因此请关注GitHub回购。