Security icon indicating copy to clipboard operation
Security copied to clipboard

how to create OAuth Authorization Server

Open vijayantkatyal opened this issue 11 years ago • 6 comments

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

vijayantkatyal avatar Apr 01 '15 20:04 vijayantkatyal

You can't, the OAuth2 authorization server has not been (and won't be) ported to ASP.NET 5: http://stackoverflow.com/questions/29055477/oauth-authorization-service-in-asp-net-mvc-6

kevinchalet avatar Apr 01 '15 23:04 kevinchalet

IdentityServer3 works fine on ASP.NET 5 (but not on the CoreClr)

https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/AspNet5Host

leastprivilege avatar Apr 02 '15 05:04 leastprivilege

@leastprivilege This line of code is busted:

https://github.com/IdentityServer/IdentityServer3.Samples/blob/master/source/AspNet5Host/src/IdentityServer3/Startup.cs#L21

It should be using IApplicationEnvironment

davidfowl avatar Apr 02 '15 05:04 davidfowl

thanks! Will update.

leastprivilege avatar Apr 02 '15 05:04 leastprivilege

For anyone still looking for the original OAuth Authorization Server in ASP.NET 5, I have ported the code and the original sample here: https://github.com/XacronDevelopment/oauth-aspnet

The port includes backwards compatibility to allow ASP.NET 4.x resource servers to read the access tokens created by the authorization server.

The nuget packages are here: https://www.nuget.org/packages/OAuth.AspNet.AuthServer https://www.nuget.org/packages/OAuth.AspNet.Tokens https://www.nuget.org/packages/OAuth.Owin.Tokens

Xacron avatar Sep 21 '15 13:09 Xacron

@Xacron thanks, will try.

vijayantkatyal avatar Sep 21 '15 19:09 vijayantkatyal