我正在按照本指南为 keycloak(2.5 版)实现自定义登录页面。我添加了自己的自定义样式,现在我正在尝试添加荷兰语语言环境。目前没有提供荷兰语语言环境,所以我提供了以下属性文件:
themes/mytheme/login/messages/messages_en.properties
themes/mytheme/account/messages/messages_en.properties
themes/mytheme/email/messages/messages_en.properties
与locale_nl=Nederlands
财产。之后,我添加了messages_nl.properties
带有翻译字符串的文件。
接下来,我将该locales=en,nl,de
属性添加到以下文件中:
themes/mytheme/login/messages/theme.properties
themes/mytheme/account/messages/theme.properties
themes/mytheme/email/messages/theme.properties
只剩下一件事要做:在管理控制台中添加荷兰语语言环境。但是NL
启用国际化后无法选择语言环境。我只能选择英语和德语语言环境,我刚刚创建的荷兰语语言环境不可用:
根据多语言支持和在 Keycloak 中添加自定义语言环境,我应该能够通过输入语言环境并点击“输入”来添加我自己的语言环境,但这没有任何作用。
我在这里错过了一步?
所以我有一个问题,让keycloak 3.2.1在kong(0.10.3)后面工作,这是一个基于nginx的反向代理.
场景是:
我通过我的网关路由来呼叫keycloak https://{gateway}/auth
,它向我显示带有keycloak徽标的入口点,链接到管理控制台等 - 到目前为止一切都很好.
但是当点击管理控制台 - >调用时https://{gateway}/auth/admin/master/console/
,keycloak尝试通过http加载其css/js(参见下面的screenie),我的浏览器因为混合内容而阻止了.
我四处搜索并找到了这个帖子:keycloak apache服务器配置带有'混合内容'问题导致这个github repo:https://github.com/dukecon/keycloak_postgres_https
从那时起,我尝试将其cli成功集成到我的dockerfile中(没有更改文件的内容,只是将它们复制到我的repo中并从dockerfile添加/运行它们).这是我的dockerfile现在:
FROM jboss/keycloak-postgres:3.2.1.Final
USER root
ADD config.sh /tmp/
ADD batch.cli /tmp/
RUN bash /tmp/config.sh
#Give correct permissions when used in an OpenShift environment.
RUN chown -R jboss:0 $JBOSS_HOME/standalone && \
chmod -R g+rw $JBOSS_HOME/standalone
USER jboss
EXPOSE 8080
Run Code Online (Sandbox Code Playgroud)
所以我现在没有想法,希望你能帮助我:
如何告诉keycloak在这里通过https调用'css-files?
我是否需要更改cli脚本中的内容?
这是脚本的内容:
config.sh:
#!/bin/bash -x
set -e
JBOSS_HOME=/opt/jboss/keycloak
JBOSS_CLI=$JBOSS_HOME/bin/jboss-cli.sh
JBOSS_MODE=${1:-"standalone"}
JBOSS_CONFIG=${2:-"$JBOSS_MODE.xml"}
echo "==> Executing..."
cd /tmp
$JBOSS_CLI --file=`dirname …
Run Code Online (Sandbox Code Playgroud) 我将使用keycloak保护我的golang应用程序,但keycloak本身不支持go语言.
有一些go适配器作为github中的一个开放项目,已经实现了openId connect协议作为提供者服务,但它们没有提供有关如何将库与应用程序集成的示例或文档.
如何使用golang与keycloak进行交互?
如何通过 Keycloak API 获取客户端密码?
在文档中我看到:
GET /admin/realms/{realm}/clients/{id}/client-secret
我的代码如下:
data = {
"grant_type" : 'password',
"client_id" : 'myclientid',
"username" : 'myusername',
"password" : 'mypassword'
}
response = requests.get("https://mylink.com/auth/admin/realms/{myrealm}/clients/{myclientid}/client-secret", data=data, headers= {"Content-Type": "application/json"})
Run Code Online (Sandbox Code Playgroud)
我总是收到 401 错误。
我做错了什么?
如何在 Keycloak 的领域中创建管理员用户?我试过/bin/add-user.sh -r myrealm -u admin -p <pwd>
它给了我错误:
* Error *
WFLYDM0065: The user supplied realm name 'myrealm' does not match the realm name discovered from the property file(s) 'ManagementRealm'.
Exception in thread "main" org.jboss.as.domain.management.security.adduser.AddUserFailedException: WFLYDM0065: The user supplied realm name 'myrealm' does not match the realm name discovered from the property file(s) 'ManagementRealm'.
at org.jboss.as.domain.management.security.adduser.ErrorState.execute(ErrorState.java:72)
at org.jboss.as.domain.management.security.adduser.AddUser.run(AddUser.java:133)
at org.jboss.as.domain.management.security.adduser.AddUser.main(AddUser.java:231)
at org.jboss.modules.Module.run(Module.java:352)
at org.jboss.modules.Module.run(Module.java:320)
at org.jboss.modules.Main.main(Main.java:593)
Run Code Online (Sandbox Code Playgroud)
我试过了 /bin/add-user-keycloak.sh -r myrealm -u admin -p <pwd>
。它要求我重新启动服务器,但我也没有看到用户。
如果有人知道如何使用 python …
有没有办法通过REST获取Keycloak领域的用户列表而不使用管理员帐户?管理控制台可能有某种可分配的角色?寻找任何想法.
现在我正在使用管理员凭据来获取访问令牌,然后使用该令牌从realm/users
端点提取用户.
获取令牌(来自node.js应用程序request
):
uri: `${keycloakUri}/realms/master/protocol/openid-connect/token`,
form: {
grant_type: 'password',
client_id: 'admin-cli',
username: adminUsername,
password: adminPassword,
}
Run Code Online (Sandbox Code Playgroud)
使用令牌:
uri: `${keycloakUri}/admin/realms/${keycloakRealm}/users`,
headers: {
'authorization': `bearer ${passwordGrantToken}`,
}
Run Code Online (Sandbox Code Playgroud)
我希望能够使用客户端应用程序中的通用用户信息(用户名,电子邮件,全名).
从(移动)应用程序调用Keycloak的注销端点时遇到问题.
支持此方案的文档中所述:
/境界/ {领域名} /协议/ OpenID的连接/注销
注销端点注销经过身份验证的用户.
可以将用户代理重定向到端点,在这种情况下,将注销活动用户会话.之后,用户代理将重定向回应用程序.
端点也可以由应用程序直接调用.要直接调用此端点,需要包含刷新令牌以及验证客户端所需的凭据.
我的请求有以下格式:
POST http://localhost:8080/auth/realms/<my_realm>/protocol/openid-connect/logout
Authorization: Bearer <access_token>
Content-Type: application/x-www-form-urlencoded
refresh_token=<refresh_token>
Run Code Online (Sandbox Code Playgroud)
但总是会出现此错误:
HTTP/1.1 400 Bad Request
Connection: keep-alive
X-Powered-By: Undertow/1
Server: WildFly/10
Content-Type: application/json
Content-Length: 123
Date: Wed, 11 Oct 2017 12:47:08 GMT
{
"error": "unauthorized_client",
"error_description": "UNKNOWN_CLIENT: Client was not identified by any client authenticator"
}
Run Code Online (Sandbox Code Playgroud)
如果我提供了access_token,Keycloak似乎无法检测到当前客户端的身份事件.我使用相同的access_token来访问其他Keycloak的API而没有任何问题,例如userinfo (/ auth/realms // protocol/openid-connect/userinfo).
我的请求是基于这个Keycloak的问题.该问题的作者得到了它的工作,但这不是我的情况.
我正在使用Keycloak 3.2.1.Final.
你有同样的问题吗?你知道如何解决它吗?
我的设置包含三个组件:
前端将使用Keycloak允许用户登录并使用访问令牌来验证对后端的请求。到目前为止,一切都很好。
现在,我希望第三方应用程序能够针对后端发出经过身份验证的请求,我想知道如何使用Keycloak来实现该请求?我的想法是为每个客户发布一组新的凭据。然后,他们的应用程序与Keycloak对话以获取访问令牌。然后,我可以使用Keycloak来管理API所有用户的访问控制。
设置aud
声明以避免下面的错误的正确方法是什么?
unable to verify the id token {"error": "oidc: JWT claims invalid: invalid claims, 'aud' claim and 'client_id' do not match, aud=account, client_id=webapp"}
Run Code Online (Sandbox Code Playgroud)
我有点解决这个错误信息,硬编码aud
声称与我的相同client_id
.有没有更好的方法?
这是我的docker-compose.yml
:
version: '3'
services:
keycloak-proxy:
image: "keycloak/keycloak-gatekeeper"
environment:
- PROXY_LISTEN=0.0.0.0:3000
- PROXY_DISCOVERY_URL=http://keycloak.example.com:8181/auth/realms/realmcom
- PROXY_CLIENT_ID=webapp
- PROXY_CLIENT_SECRET=0b57186c-e939-48ff-aa17-cfd3e361f65e
- PROXY_UPSTREAM_URL=http://test-server:8000
ports:
- "8282:3000"
command:
- "--verbose"
- "--enable-refresh-tokens=true"
- "--enable-default-deny=true"
- "--resources=uri=/*"
- "--enable-session-cookies=true"
- "--encryption-key=AgXa7xRcoClDEU0ZDSH4X0XhL5Qy2Z2j"
test-server:
image: "test-server"
Run Code Online (Sandbox Code Playgroud) 有一个在本地运行的网络服务器,我想在 iframe 内有 Keycloak(在另一个域上)登录页面。我在 Keycloak Real Settings > Security Defenses > Headers > Content-Security-Policy 中尝试了以下设置
frame-src 'self' http://127.0.0.1 http://192.168.1.140 http://localhost *.home-life.hub http://trex-macbook.home-life.hub localhost; frame-ancestors 'self'; object-src 'none';
Run Code Online (Sandbox Code Playgroud)
基本上,我将本地 IP 地址和主机名作为frame-src
.
登录页面未显示,我在浏览器控制台中收到此错误
Refused to display 'http://keycloak.example.com:8080/auth/realms/master/protocol/openid-connect/auth?client_id=es-openid&response_type=code&redirect_uri=https%3A%2F%2Fkibana.example.com%3A5601%2Fauth%2Fopenid%2Flogin&state=3RV-_nbW-RvmB8EfUwgkJq&scope=profile%20email%20openid' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".
Run Code Online (Sandbox Code Playgroud)
我的服务器和 UI(服务器呈现)代码:
'use strict';
const Hapi = require('@hapi/hapi');
const init = async () => {
// Run server on all interfaces
const server = Hapi.server({
port: 3000, …
Run Code Online (Sandbox Code Playgroud)