1

Is it possible to get the root url in the Freemaker's template used by Keycloak login theme? The closest one I found is inside the client bean:

keycloak-master\services\src\main\java\org\keycloak\forms\login\freemarker\model\ClientBean.java


public String getBaseUrl() {
  return ResolveRelative.resolveRelativeUri(session, client.getRootUrl(), client.getBaseUrl());
}

Which can be called in a Freemaker tamplete:

${client.baseUrl}

However, the client.getRootUrl() itself is not exposed. Is it possible to get root url without changing the service source code, just using the Freemaker template in the Keycloak theme?

JoshThunar
  • 452
  • 1
  • 6
  • 15

1 Answers1

2

If it's just for displaying it in the page, use Javascript and it'll be evaluated at client side:

<label id="yourLabel">test</label>
<script>
  var root = window.location.origin;
  document.getElementById('yourLabel').innerHTML = root;
</script>

See also:

Aritz
  • 30,971
  • 16
  • 136
  • 217