Keycloak/Undertow/JBoss-CLI - 设置“web-context";从环境变量 [英] Keycloak/Undertow/JBoss-CLI - Set "web-context" from environment variable

查看:39
本文介绍了Keycloak/Undertow/JBoss-CLI - 设置“web-context";从环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 Wildfly/Undertow 和 JBoss-CLI 设置 Keycloak 网络上下文的问题.

I've a problem regarding Wildfly/Undertow and the JBoss-CLI setting the web-context of Keycloak.

环境变量在 undertow 本身似乎没有被解析,但其他环境变量似乎被解析.

The environment-variable seems not to be resolved in undertow itself, but other environment-variable seems to be resolved.

我创建了以下 CLI 脚本:

I've create the following CLI-script:

/subsystem=keycloak-server/:write-attribute(name=web-context,value=${env.KEYCLOAK_WEB_CONTEXT:auth})

由 docker build 执行,standalone.xml 中的结果看起来也不错:)

which is executed by the docker build and the result in the standalone.xml also looks good :)

当启动 Keycloak-Service 时,它​​不会解析变量,它只会使用变量本身:

When starting the Keycloak-Service it does not resolve the variable, it will just use the variable itself:

14:30:30,556 INFO  [org.wildfly.extension.undertow] (ServerService
Thread Pool -- 60) WFLYUT0021: Registered web context:
'/${env.KEYCLOAK_WEB_CONTEXT:auth}' for server 'default-server'

在将 jboss-cli.sh 连接到容器并请求我得到的变量后:

After connecting with the jboss-cli.sh to the container and requesting the variables I got:

[standalone@localhost:9990 subsystem=keycloak-server] ls -l
ATTRIBUTE VALUE TYPE
web-context ${env.KEYCLOAK_WEB_CONTEXT:auth} STRING

使用解析表达式:

[standalone@localhost:9990 subsystem=keycloak-server] ls -l --resolve-expressions
ATTRIBUTE VALUE TYPE
web-context helloworld/auth  STRING

所以到目前为止一切看起来都很好.任何想法为什么 Undertow 从变量而不是已解析的变量开始?这是一个潜在的错误吗?

So everything looks good so far. Any ideas why Undertow starts with the variable and not the resolved variable? Is it a potential bug?

最好的问候并感谢您的帮助!

Best regards and thank you for any help!

推荐答案

我知道这已经两年了,但我最近在尝试解决这个问题并且我想通了,所以我想如果有人来我会跟进穿过这个.

I know this is two years old, but I was recently trying to solve this problem and I figured it out so I figured I'd follow up if anyone comes across this.

不要在表达式中使用 ${env.VAR} 模式,而是在脚本顶部使用它们作为变量赋值.借用父示例:

Instead of using the ${env.VAR} pattern in your expression, use them in the top of the script as a variable assignment. Borrowing from the parent example:

set CONTEXT=${env.KEYCLOAK_WEB_CONTEXT}
/subsystem=keycloak-server/:write-attribute(name=web-context,value=$CONTEXT)

环境变量作为 $CONTEXT 的值被引入,即使它在 write-attribute 行中使用时从未对我有用.

The environment variable gets pulled in as the value of $CONTEXT, even though it never worked for me when used in the write-attribute line.

这篇关于Keycloak/Undertow/JBoss-CLI - 设置“web-context";从环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆