ASP.NET V5多SigningCredentials [英] ASP.NET v5 Multiple SigningCredentials

查看:524
本文介绍了ASP.NET V5多SigningCredentials的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.NETv4我用:

In ASP.NETv4 I used:

var signingKey = new HmacSigningCredentials(keyByteArray);

但在V5的最后一个参数新JwtSecurityToken() SigningCredentials ,而不是 HmacSigningCredentials

于是,我尝试使用:

var signingKey = new System.IdentityModel.Tokens.SigningCredentials();

但是,这给我的错误类型SigningCredentials存在于两个System.IdentityModel.Tokens和System.IdentityModel

我该如何解决这个问题?

How do I fix this?

这是我的依赖关系:

"dependencies": {
    "EntityFramework.Commands": "7.0.0-beta8",
    "EntityFramework.SqlServer": "7.0.0-beta8",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta8",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta8",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
    "Microsoft.AspNet.Mvc": "6.0.0-beta8",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta8",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta8",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta8",
    "Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta8",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
    "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta8",
    "Microsoft.Framework.Logging": "1.0.0-beta8",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta8",
    "Microsoft.Framework.Logging.Debug": "1.0.0-beta8",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta8",
    "Thinktecture.IdentityModel.Core": "1.4.0",
    "Microsoft.Owin.Security": "3.0.1",
    "System.IdentityModel.Tokens.Jwt": "5.0.0-beta8-209291029",
    "Microsoft.AspNet.Identity.Owin": "2.2.1"
},

从我所知道的,矛盾是这些依赖的:

From what I can tell, the conflict is between these dependencies:

    "Microsoft.AspNet.Identity.Owin": "2.2.1"
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8"

如果我删除了实体框架,那我失去的东西像公共类用户:IdentityUser ,如果我删除Owin一个,那么我失去的东西像 OAuthAuthorizationServerProvider

If I remove the Entity Framework one, then I lose things like public class User : IdentityUser, if I remove the Owin one, then I lose things like OAuthAuthorizationServerProvider.

我似乎被卡住。

推荐答案

您遇到的问题,直接的原因是你在引用这两个ASP.NET身份2和3的身份包的事实:身份2引用IdentityModel 4(附带完整的.NET框架),而新的堆栈使用IdentityModel 5.不幸的是,无论是不相容的,不能在同一个项目中引用。
你可以在这里找到更多信息:<一href=\"http://stackoverflow.com/questions/31700074/ambiguous-reference-issue-microsoft-aspnet-identity-microsoft-aspnet-identity\">Ambiguous参考号(Microsoft.AspNet.Identity&安培; Microsoft.AspNet.Identity.Core)

The issue you're seeing is directly due to the fact you're referencing both ASP.NET Identity 2 and Identity 3 packages: Identity 2 references IdentityModel 4 (that comes with the full .NET framework) while the new stack uses IdentityModel 5. Sadly, both are incompatible and can't be referenced in the same project. You can find more information here: Ambiguous reference issue (Microsoft.AspNet.Identity & Microsoft.AspNet.Identity.Core)

删除你的 Microsoft.AspNet.Identity.Owin / Microsoft.Owin.Security 引用和它应该工作。

Remove your Microsoft.AspNet.Identity.Owin/Microsoft.Owin.Security references and it should work.

如果您需要使用ASP.NET的5部作品来替代 OAuthAuthorizationServerMiddleware ,你可以看看这个其他SO问题:<一href=\"http://stackoverflow.com/questions/30768015/configure-the-authorization-server-endpoint/30788109\">Configure授权服务器端点

If you need an alternative to OAuthAuthorizationServerMiddleware that works with ASP.NET 5, you can take a look at this other SO question: Configure the authorization server endpoint

这篇关于ASP.NET V5多SigningCredentials的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆