Templates

Using your own templates

Dex supports using your own templates and passing arbitrary data to them to help customize your installation.

Steps:

  1. Copy contents of the web directory over to a new directory.
  2. Customize the templates as needed, be sure to retain all the existing variables so Dex continues working correctly. (Use the following syntax to render values from frontend.extra config: {{ "your_key" | extra }})
  3. Set the frontend.dir value to your own web directory (Alternatively, you can set the DEX_FRONTEND_DIR environment variable).
  4. Add your custom data to the Dex configuration frontend.extra. (optional)
  5. Change the issuer by setting the frontend.issuer config in order to modify the Dex title and the Log in to <<dex>> tag. (optional)
  6. Create a custom theme for your templates in the themes directory. (optional)

Here is an example configuration:

  1. frontend:
  2. dir: /path/to/custom/web
  3. issuer: my-dex
  4. extra:
  5. tos_footer_link: "https://example.com/terms"
  6. client_logo_url: "../theme/client-logo.png"
  7. foo: "bar"

To test your templates simply run Dex with a valid configuration and go through a login flow.

Customize the official container image

Dex is primarly distributed as a container image. The above guide explains how to customize the templates for any Dex instance.

You can combine that with a custom Dockerfile to ease the deployment of those custom templates:

  1. FROM ghcr.io/dexidp/dex:latest
  2. ENV DEX_FRONTEND_DIR=/srv/dex/web
  3. COPY --chown=root:root web /srv/dex/web

Using the snippet above, you can avoid setting the frontend.dir config.