简体   繁体   English

keycloak管理员cli无法验证

[英]keycloak admin cli unable to authenticate

I am new to keycloak. 我是keycloak的新手。 I have been following the admin cli guide to automate realm creation ( inside a dockerfile ). 我一直在遵循cli cli指南来自动化领域创建(在dockerfile中)。 The kcadm call to create realm is failing with authentication error - " HTTP error - 401 Unauthorized ". 创建领域的kcadm调用失败,并显示身份验证错误-“ HTTP错误 -401 未经授权 ”。

These are the 3 lines which I am trying to execute and the exception is thrown at the last line - 这是我要执行的3行,最后一行抛出异常-

i) $JBOSS_HOME/bin/add-user-keycloak.sh -r master -u uadmin -p ${UADMIN_PWD} i)$ JBOSS_HOME / bin / add-user-keycloak.sh -r master -u uadmin -p $ {UADMIN_PWD}

( started the keycloak server after this ) (此后启动了keycloak服务器)

ii) $JBOSS_HOME/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master -user uadmin --password ${UADMIN_PWD} ii)$ JBOSS_HOME / bin / kcadm.sh配置凭据--server http:// localhost:8080 / auth --realm master -user uadmin --password $ {UADMIN_PWD}

iii) $JBOSS_HOME/bin/kcadm.sh create realms -s realm=myrealm -s enabled=true iii)$ JBOSS_HOME / bin / kcadm.sh创建领域-s realm = myrealm -s enabled = true

Top of the stack is here - 堆栈顶部在这里-

04:53:48,721 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-1) RESTEASY002005: 
Failed executing POST /admin/realms:org.jboss.resteasy.spi.UnauthorizedException: Bearer
at org.keycloak.services.resources.admin.AdminRoot.authenticateRealmAdminRequest(AdminRoot.java:160)
    at org.keycloak.services.resources.admin.AdminRoot.getRealmsAdmin(AdminRoot.java:209)

I inspected the $HOME/.keycloak/kcadm.config file and the content is as below - 我检查了$ HOME / .keycloak / kcadm.config文件,内容如下-

$ cat kcadm.config
{
  "serverUrl" : "http://localhost:8080/auth",
  "realm" : "master",
  "endpoints" : { }
}

There is no authentication token , which I could see there. 没有身份验证令牌,我可以在那里看到。

( One more observation, the "config credentials" command does not throw any exception if an invalid credential is passed. It would be helpful if there is an exception thrown. ) (另一个观察结果,如果传递了无效的凭据,“配置凭据”命令不会引发任何异常。如果引发异常,这将很有帮助。)

Any pointers for what am I doing wrong here, for the authentication issue during realm creation ? 关于领域创建期间的身份验证问题,我在这里做错什么的任何指示?

Actually there was a typo error in the command -- 实际上命令中有错别字-

"ii) $JBOSS_HOME/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master -user uadmin --password ${UADMIN_PWD} " “ ii)$ JBOSS_HOME / bin / kcadm.sh配置凭据--server http:// localhost:8080 / auth --realm master -user uadmin --password $ {UADMIN_PWD}”

The user parameter was "-user" , which should have been "--user" 用户参数是“ -user”,应该是“ --user”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM