简体   繁体   English

Keycloak:使查询字符串参数在标记 FreeMarker 模板中可用

[英]Keycloak: Make query string param available in marker FreeMarker template

Context: using https://www.keycloak.org/ as an authentication provider.上下文:使用https://www.keycloak.org/作为身份验证提供程序。

I have a use case where I need to render a block of HTML depending on the value of a query string param in the login page.我有一个用例,我需要根据登录页面中查询字符串参数的值呈现 HTML 块。 The value will be coming from the login URL similar to this:该值将来自与此类似的登录 URL:

http://localhost:8080/auth/realms/default/protocol/openid-connect/auth?...&customvar=1

I would like to have customvar available in the login.ftl to accomplish my objective.我想在customvar中使用login.ftl来实现我的目标。 So far I have tried to retrieve the baseUrl from the client bean, but it's not available, the app crashes when I attempt to access baseUrl.到目前为止,我已经尝试从客户端 bean 中检索 baseUrl,但它不可用,当我尝试访问 baseUrl 时应用程序崩溃。 I have also attempted to access the request url in the ${url} , but it's not available either.我还尝试访问${url}的请求 url,但它也不可用。

Thanks in advance for any help.在此先感谢您的帮助。

尝试 href="${client.baseUrl}" 它应该返回一个客户端 baseUrl。

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

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