首页 > 解决方案 > 我可以在 Grafana 上使用什么 IdentityServer4 Oauth

问题描述

IdentityServer4用来设置一台服务器并InMemoryConfiguration.cs初始化我的数据

InMemoryConfiguration.cs

new Client
{
   ClientId = "client.api.service",
   ClientSecrets = new [] { new Secret("clientsecret".Sha256()) },
   RedirectUris = { $"http://10.228.51.220:3000/login/generic_oauth" ,
                    $"http://10.228.51.221:56458/signin-oidc",
                    $"http://10.228.51.220:3000/signin-oidc",
                    $"http://localhost:12415/signin-oidc"},
   AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
   AllowedScopes = new [] {
           IdentityServerConstants.StandardScopes.OpenId,
           IdentityServerConstants.StandardScopes.Profile,
           IdentityServerConstants.StandardScopes.Email,
           "agentservice", "clientservice", "productservice"
   },
},
new Client
{
   ClientId = "product.api.service",
   ClientSecrets = new [] { new Secret("productsecret".Sha256()) },
   RedirectUris = { $"http://10.228.51.220:3000/login/generic_oauth" ,
                    $"http://10.228.51.221:56458/signin-oidc",
                    $"http://10.228.51.220:3000/signin-oidc",
                    $"http://localhost:12415/signin-oidc"},
   AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
   AllowedScopes = new [] {
           IdentityServerConstants.StandardScopes.OpenId,
           IdentityServerConstants.StandardScopes.Profile,
           IdentityServerConstants.StandardScopes.Email,
           "agentservice", "clientservice", "productservice"
   },
 },
 new Client
 {
    ClientId = "agent.api.service",
    ClientSecrets = new [] { new Secret("agentsecret".Sha256()) },
    RedirectUris = { $"http://10.228.51.220:3000/login/generic_oauth" ,
                     $"http://10.228.51.221:56458/signin-oidc",
                     $"http://10.228.51.220:3000/signin-oidc",
                     $"http://localhost:12415/signin-oidc"},
    AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
    AllowedScopes = new [] {
           IdentityServerConstants.StandardScopes.OpenId,
           IdentityServerConstants.StandardScopes.Profile,
           IdentityServerConstants.StandardScopes.Email,
           "agentservice", "clientservice", "productservice"
    },
 },
 new Client
 {
    ClientId = "cas.mvc.client.implicit",
    ClientName = "CAS MVC Web App Client",
    AllowedGrantTypes = GrantTypes.Implicit,
    RedirectUris = { $"http://10.228.51.220:3000/login/generic_oauth" ,
                     $"http://10.228.51.221:56458/signin-oidc",
                     $"http://10.228.51.220:3000/signin-oidc",
                     $"http://localhost:12415/signin-oidc",
                     $"http://10.228.51.220:3000/login"},
    PostLogoutRedirectUris = { $"http://10.228.51.220:3000/login/generic_oauth",
                               $"http://localhost:12415/signin-oidc",
                               $"http://10.228.51.220:3000",
                               $"http://10.228.51.220:3000/login"},
     AllowedScopes = new [] {
             IdentityServerConstants.StandardScopes.OpenId,
             IdentityServerConstants.StandardScopes.Profile,
             IdentityServerConstants.StandardScopes.Email,
             "agentservice", "clientservice", "productservice"
     },
     AllowAccessTokensViaBrowser = true // can return access_token to this client

 },

Grafana但如果我使用点击Oauth登录,它就无法工作。它显示

对不起,出现了一个错误 :

未授权客户端请求 ID:0HLU6VUML3LN5:00000002

我设置RedirectUris但它不能解决这个问题。我能解决什么问题?

标签: c#grafana

解决方案


推荐阅读