3

如何在 ASP.NET 5 中注册OAuthAuthorizationServerMiddleware和?OAuthBearerAuthenticationMiddleware

我尝试了以下方法:

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 中。

我在这里碰壁了,无法注册 OAuth 服务器中间件和 OAuth Bearer 身份验证。

4

1 回答 1

5

您不能在 ASP.NET vNext 项目中使用带有 UseMiddleware 方法的 Katana 项目的中间件。您可以尝试此处提供的 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

于 2014-10-23T16:29:14.820 回答