【问题标题】:IdentityServer4 IssuesIdentityServer4 问题
【发布时间】:2016-09-28 20:53:28
【问题描述】:

我正在使用 IdentityServer4 创建 Web API 安全性。我通过在控制台管理器中键入以下语法安装了 identityserver4 包:Install-Package IdentityServer4 -Pre。它安装成功。现在我无法在我的项目中引用它。 这是我安装后的project.json代码:

{
    "webroot": "wwwroot",
    "version": "1.0.0-*",

    "dependencies": {
        "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
        "IdentityServer4": "1.0.0-rc1-update2"
    },

    "commands": {
        "web": "Microsoft.AspNet.Hosting --config hosting.ini"
    },

    "frameworks": {
        "dnx451": { },
        "dnxcore50": { }
    },

    "publishExclude": [
        "node_modules",
        "bower_components",
        "**.xproj",
        "**.user",
        "**.vspscc"
    ],
    "exclude": [
        "wwwroot",
        "node_modules",
        "bower_components"
    ]
}

所以现在我用以下代码创建了一个客户端类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace LearningIdentityServer4.OAuth
{
    public class Clients
    {
        public static IEnumerable<Client> Get()
        {
            return new[]
            {
                new Client
                {
                    ClientId = "myApi",
                    ClientSecrets = new List<Secret>
                    {
                        new Secret("secret".Sha256())
                    },
                    ClientName = "My lovely Api",
                    Flow = Flows.ResourceOwner,
                    AllowedScope =
                    {
                        Constants.StandardScope.OpenId,
                        "read"
                    },
                    Enabled = true
                }
            };
        }
    }
}

所以我得到了很多错误。当我将鼠标悬停在第一个客户端上时,我得到的唯一选项是 Add Package IdentityServer3 2.1.1

那么我如何引用 IdentityServer4 而不是 IdentityServer3 2.1.1

我期待收到您的来信。

谢谢,索马德

【问题讨论】:

标签: identityserver4


【解决方案1】:

那些框架已经完全过时了。

要使用identityserver4,您需要(至少)依赖netcoreapp 1.0 框架并添加一些依赖项。将 project.json 中的框架替换为以下内容:

"frameworks": {
"netcoreapp1.0": {
  "imports": [
    "dotnet5.6",
    "portable-net45+win8"
  ]
}
},

另见samples。我假设您的工具已经过时,或者您正在再次打开一个旧项目。 ASP.NET Core 改变了很多东西。

【讨论】:

    猜你喜欢
    • 2021-05-22
    • 2023-03-25
    • 2020-09-12
    • 2018-12-08
    • 1970-01-01
    • 2019-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多