注册OAuth授权服务中间件

Raj*_*mar 3 owin katana asp.net-core

我怎样才能注册OAuthAuthorizationServerMiddleware,并OAuthBearerAuthenticationMiddleware在ASP.NET 5?

我尝试了以下方法:

app.UseMiddleware(typeof(OAuthAuthorizationServerMiddleware), OAuthServerOptions);
app.UseMiddleware(typeof(OAuthBearerAuthenticationMiddleware), new OAuthBearerAuthenticationOptions());
Run Code Online (Sandbox Code Playgroud)

但是这会引发以下错误:

System.Exception: TODO: unable to locate suitable constructor for Microsoft.Owin.Security.OAuth.OAuthBearerAuthenticationMiddleware. Ensure 'instanceType' is concrete and all parameters are accepted by a constructor.
Run Code Online (Sandbox Code Playgroud)

我正在尝试将在此(单击此处)应用程序中实现的基于令牌的身份验证移植到ASP.NET 5中.

我在这里遇到了障碍,无法注册OAuth服务器中间件和OAuth承载身份验证.

tug*_*erk 5

您不能在ASP.NET vNext项目中使用Katana项目中的中间件和UseMiddleware方法.您可以尝试使用此处提供的UseOwin方法:https://github.com/aspnet/HttpAbstractions/blob/335895d9b49042312eca12a089340adf3ca0a219/src/Microsoft.AspNet.Owin/OwinExtensions.cs但我不确定它是如何工作的.

这里最明智的决定是把你的东西搬到新的世界.您可以在此处找到OAuth服务器中间件实现:https://github.com/aspnet/Security/tree/dev/src/Microsoft.AspNet.Security.OAuth