Spring boot 是否可以创建没有管理员凭据的KeyClope用户?

Spring boot 是否可以创建没有管理员凭据的KeyClope用户?,spring-boot,keycloak,keycloak-rest-api,Spring Boot,Keycloak,Keycloak Rest Api,我有一个SpringBoot应用程序,它使用KeyClope进行用户管理。但是keybeave实例是一个生产实例,我没有管理员凭据。我将提供以下keydave领域信息 #Keycloak settings keycloak.auth-server-url=https://myapp.com/auth/ keycloak.realm=project-realm keycloak.resource=project-client keycloak.credentials.secret=secret k

我有一个SpringBoot应用程序,它使用KeyClope进行用户管理。但是keybeave实例是一个生产实例,我没有管理员凭据。我将提供以下keydave领域信息

#Keycloak settings
keycloak.auth-server-url=https://myapp.com/auth/
keycloak.realm=project-realm
keycloak.resource=project-client
keycloak.credentials.secret=secret
keycloak.use-resource-role-mappings=true
keycloak.bearer-only=true
keycloak.ssl-required=external
auth.token.url=https://myapp.com/auth/realms/my-realm/protocol/openid-connect/token
auth.grant.type=client_credentials
当我尝试使用KeyClope rest api执行用户管理操作时,我得到403禁止响应。这里,授权令牌是使用上述领域凭据生成的

method: POST 
url:https://myapp.com/auth/realms/project-realm/protocol/openid-connect/token
contentType: application/x-www-form-urlencoded
body:
client_id: project-client
grant_type: client_credentials
client_secret: secret 
但是,当我使用本地keydape实例并使用管理员凭据生成授权令牌时,这一切都很正常

method: POST 
url:http://localhost:8180/auth/realms/master/protocol/openid-connect/token
contentType: application/x-www-form-urlencoded
body:
client_id: admin-cli
grant_type: password
username: admin
password: admin
我需要知道的是,我是否需要管理员凭据(用户名、密码)来使用KeyClope rest api执行这些用户管理操作?还是我做错了什么

当我尝试使用KeyClope rest执行用户管理操作时 api我得到403禁止响应。这里是授权令牌 使用上述领域凭据生成

这是因为

method: POST 
url:https://myapp.com/auth/realms/project-realm/protocol/openid-connect/token
contentType: application/x-www-form-urlencoded
body:
client_id: project-client
grant_type: client_credentials
client_secret: secret 
您的客户端<代码>项目客户端没有适当的管理员相关角色来执行管理员Rest API调用

我需要知道的是我是否需要管理员凭据(用户名, 密码)来使用keyclaok执行这些用户管理操作 RESTAPI?还是我做错了什么

不可以。您可以与其他用户或客户端执行相同的任务,只要他们具有适当的角色。要解决问题,您可以执行以下操作:

  • 转到客户
    项目客户
    所在的领域
    
  • 转到客户并选择客户
    项目客户
  • 切换到选项卡
    服务帐户角色
  • 客户端角色
    下拉菜单中选择
    领域管理
  • 相应地选择并分配角色: