1
votes

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());

how to do this in asp.net 5 (vnext).

references:

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

1

1 Answers

0
votes

Microsoft has decided not to migrate the OWIN OAuth Authorization Server middleware to ASP.NET 5, so I have done it myself. You can find the source at the following GitHub repo https://github.com/XacronDevelopment/oauth-aspnet or you can just use the NuGet packages OAuth.AspNet.AuthServer and OAuth.AspNet.Tokens in your ASP.NET 5 projects. Refer to the samples in the GitHub repo to see how to wire things up.

Note that the current version of this port supports ASP.NET 5 Beta 7 only. Support for nightly builds of Beta 8 will be added in a few days, so keep an eye on the GitHub repo.