Templates

The Token Server uses the Thymeleaf template engine to serve pages to the end user via a browser. To align the Token Server look and feel with your mobile application or company standards the templates can be customized.

Customizing templates

Customized templates can be uploaded and managed via the Token Server admin console. The Token Server uses template sets which contain one or more custom templates. When a specific template is not available in the template set the default template is used. Via the template section template sets can be added and removed. One template set can be marked as the default template set. To add a custom template set, a zip file containing the templates should be uploaded. The templates should be in the root of the archive. As a reference for the custom template set archive please refer to the default template set.

In the templates the Thymeleaf Layout Dialect and Thymeleaf With Dialect are supported. The template file names are hardcoded and should be equal in the custom template set. The internals of the template like message keys and fragments can be different. For more details about the different templates supported by the Token Server see the templates section in the appendix.

To distribute a templates set from for example a test environment to a production environment it can be exported and imported on the other system. Different versions of a template set can be uploaded by giving them a different name. So it is easy to switch between an old and a new set.

When developing a template set you might need to upload a new zip frequently. To see the effect of uploading a modified set of templates template caching should be disabled or the Token Server Engine docker should be restarted. To configure Thymeleaf template caching use the config property: Template caching enabled

Template sets

Configuring an application specific template set

For each mobile application and web client a template set can be configured to render screens in the look and feel of this application or web client. When no template set is configured for an application or web client, the default template set is used to render these screens.

App template set

Resolving templates

Onegini Token Server tries to resolve templates in the following order:

  1. Within the template set that is configured for the application or web client of the current request.
  2. When the template is not present in this set, within the template set that is marked as the default template set.
  3. When no template set is marked as default or when the template is not found, within the templates that are bundled with Onegini Token Server.

Static resources

An application server like the Token Server is not optimized for server static resources like javascript, images and css files. Therefore the Token Server does not support serving custom static resources. Some options on how to use custom static resources:

  • Embed the static resources in the html of the templates. The downside is that the client cannot cache the static resource.
  • Serve the static resources via the organisations content management system.
  • Serve the static resources via the Onegini Content Server, docker based micro service which can optionally be deployed next to the Token Server.