16

I'am googling for a while in order to find a documentation of all available say "variables" I can use in the various Keycloak templates. by variable I mean all the ${xxx.yyy} things I can use to inject some dynamic values inside the template.

Through the documentation I can find here and there some of them (like ${user.attributes} or ${url.resourcesPath}) but are there others than these ?

Does anyone have a reference link ?

Many Thanks

Ghurdyl
  • 1,077
  • 1
  • 12
  • 18

3 Answers3

17

You can look for the template providers in Keycloak's code.

All the templates are "ftl" files filled with a map called "attributes". Keycloak has a couple of classes which fill those templates with Beans depending on the page or action as CharlyP mentioned. For example:

kinjelom
  • 6,105
  • 3
  • 35
  • 61
Luis Mira
  • 171
  • 2
11

I did not find any easy to use documentation but I found the Keycloak Javadocs which can be helpful when you look for the *Bean classes of this documentation. These classes seem to be the ones available in most of the templates. And their public methods will match the available properties you can use in the templates.

For example: You want to know the properties available for the variable url you can check the class UrlBean in the documentation and you will find for example a method getLoginUrl. This means you can access the property url.loginUrl.

That's all I could find for the time being. Hope it will be helpful...

Juan
  • 4,910
  • 3
  • 37
  • 46
CharlyP
  • 181
  • 1
  • 4
  • 2
    It certainly helps. I just fear that without a doc, these properties might no longer be available from updates to updates. It's also worth pointing that all properties of a given `*Bean` are not necessarily present all together and if a missing property is used, the template generation fails. – Ghurdyl May 31 '18 at 10:06
  • 3
    Indeed! Quite painful to dev and debug without any proper tooling and documentation... – CharlyP Jun 01 '18 at 10:48
  • 2
    didn't understand why they do like that... I spent to much time >_< !! – Eng Jan 25 '21 at 11:32
  • 6
    Link seems to be broken :/ – Powersource Jun 14 '21 at 11:48
  • Newest link can be found here: https://www.keycloak.org/documentation under API Documentation there is a link to the newest JavaDoc documentation. – Beast Dec 15 '22 at 14:56
0

Keycloak templates available variables:

<#import "template.ftl" as layout>
<@layout.emailLayout>
<img src="https://domain.tld">


<h1>Thanks for signing up!</h1>
<p> Please verify email address ${user.email} <br>activate your account and to proceed registration process.</p>
</@layout.emailLayout>

Originaly found on Keycloak - How to select the email verification template when sending an email using Keycloak's Admin REST API?

Good luck !

David Bister
  • 61
  • 1
  • 6