小编Faw*_*iqi的帖子

IdentityServer4对基于角色的Web API授权

我使用IdentityServer4(v2.2.1)与.Net Core 2.0和Asp.Net核心身份.我的解决方案中有三个项目.

  1. IdentityServer
  2. Web API
  3. MVC Web应用程序

我正在尝试在我的Web API上实现基于角色的授权,以便任何客户端都可以将访问令牌传递给Web API以访问资源.

目前我可以在MVC应用程序控制器上实现Roles基础授权,但我无法为WEB API Controller传递/配置相同的权限.

以下是Identity Server Files:Config.cs

public static IEnumerable<ApiResource> GetApiResources()
    {
        return new List<ApiResource>
        {
            //SCOPE - Resource to be protected by IDS 
            new ApiResource("TCSAPI", "TCS API")
            {
                UserClaims = { "role" }
            }
        };
    }


 public static IEnumerable<Client> GetClients()
    {
        return new List<Client>
        {
new Client
            {
                ClientId = "TCSIdentity",
                ClientName = "TCS Mvc Client Application .",
                AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
                RequireConsent = false,
                ClientSecrets =
                {
                    new Secret("secret".Sha256()) …
Run Code Online (Sandbox Code Playgroud)

identityserver4 asp.net-core-identity

6
推荐指数
1
解决办法
3927
查看次数

请求发现底座时出错(需要HTTPS)

我正在使用身份服务器4。事实上,它仍然可以正常工作,一切正常。但是当我尝试打电话时

var client = new HttpClient();
// discover endpoints from metadata
var disco = client.GetDiscoveryDocumentAsync(IDPBaseURL).Result;
it gives me error         
http://xxx.x.x.xx:8080/.well-known/openid-configuration: HTTPS required.
Run Code Online (Sandbox Code Playgroud)

它可以在Visual Studio和本地IIS部署中使用。但是我仅在服务器上部署时才遇到此错误。

任何的想法?

c# dotnet-httpclient asp.net-core identityserver4

3
推荐指数
2
解决办法
675
查看次数