Search code examples
themeskeycloak

How to access email resource path in Keycloak?


I am customizing the email template for password-reset. I wish to access the logo from email resources directory (i.e) \themes\\email\resources\img\marketing.jpg

This can be possible for login module via ${url.resourcesPath}

Some one please point out me how to access the email resource path in password-reset.ftl

version keycloak-4.0.0.Final


Solution

  • I developed a custom plugin within Keycloak 4.3.0.Final to address a specific issue. Following that, I made a contribution to the Keycloak community, which ultimately led to the resolution of the problem in Keycloak version 8.0.0.

    ${url.resourcesUrl} works from

    keycloak version 8.0.0

    You can find the details of this contribution in the following GitHub pull request: https://github.com/keycloak/keycloak/pull/6512

    Regarding the usage of the ftl file, you can incorporate the provided code snippet to embed font and image resources:

    <style>
      @font-face {
        font-family: 'Roboto';
        src: url('${url.resourcesUrl}/fonts/Roboto/Roboto-Regular.eot');
      }
    </style>
    .
    .
    .
    <img src="${url.resourcesUrl}/img/company_logo.svg" alt="logo">