注册OAuth授权服务中间件 [英] Registering OAuth authorization service middleware
问题描述
如何在ASP.NET 5中注册OAuthAuthorizationServerMiddleware
和OAuthBearerAuthenticationMiddleware
?
How can i register the OAuthAuthorizationServerMiddleware
and OAuthBearerAuthenticationMiddleware
in ASP.NET 5?
我尝试了以下操作:
app.UseMiddleware(typeof(OAuthAuthorizationServerMiddleware), OAuthServerOptions);
app.UseMiddleware(typeof(OAuthBearerAuthenticationMiddleware), new OAuthBearerAuthenticationOptions());
但这会引发以下错误:
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.
我正在尝试移植在此实现的基于令牌的身份验证(单击此处)应用程序进入ASP.NET 5.
I'm trying to port token based authentication implemented in this (click here) application into ASP.NET 5.
我在这里碰壁,无法注册OAuth服务器中间件和OAuth Bearer身份验证.
I've hit a wall here, not being able to register the OAuth server middleware and OAuth Bearer authentication.
推荐答案
在ASP.NET vNext项目中,不能将Katana项目中的中间件与UseMiddleware方法一起使用.您可以尝试在此处提供的UseOwin方法: https://github.com/aspnet/HttpAbstractions/blob/335895d9b49042312eca12a089340adf3ca0a219/src/Microsoft.AspNet.Owin/OwinExtensions.cs ,但我不确定它的工作方式.
You cannot use middlewares from Katana project with UseMiddleware method in an ASP.NET vNext project. You can try UseOwin method provided here: https://github.com/aspnet/HttpAbstractions/blob/335895d9b49042312eca12a089340adf3ca0a219/src/Microsoft.AspNet.Owin/OwinExtensions.cs but I'm not sure how it's going to work.
这里最明智的决定是将您的东西移植到新世界.您可以在此处找到OAuth Server中间件实现: https://github.com/aspnet/Security/tree/dev/src/Microsoft.AspNet.Security.OAuth
The wisest decision here is to port your stuff to new world. You can find the OAuth Server middleware implementations here: https://github.com/aspnet/Security/tree/dev/src/Microsoft.AspNet.Security.OAuth
这篇关于注册OAuth授权服务中间件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!