Toggle menu

Handlebars Templates

The Authentication worker uses Handlebars templates to generate the HTML used in site login forms, account management pages and consent messages. These templates can be overridden by named provider, provider type, and by subsite.

Default Templates

There are three different kinds of template. By default they are found at <API Server Root>\workers\auth\<version>\templates

Top Level Login

The top level templates provide the page header and body content of the main login form. The templates of enabled providers are pulled into this template as part of the page render.

\loginform\body.hbs
\loginform\header.hbs

Generic Actions

These actions include the templates used for account management, mismatched (update prompt) email messages, user consent,  and user linking. Actions can be overridden on a per-provider or subsite basis.

\actions\accountmanagement\options\body.hbs
\actions\accountmanagement\options\header.hbs
\actions\emailupdate\body.hbs
\actions\emailupdate\header.hbs
\actions\getuserconsent\body.hbs
\actions\getuserconsent\header.hbs
\actions\twofactorauthentication\confirmationemail\body.hbs
\actions\twofactorauthentication\confirmationemail\subject.hbs
\actions\userlinking\confirmationemail\body.hbs
\actions\userlinking\confirmationemail\subject.hbs
\actions\userlinking\confirmationemailsent\body.hbs
\actions\userlinking\confirmationemailsent\header.hbs
\actions\userlinking\newuserlinkingoptions\body.hbs
\actions\userlinking\newuserlinkingoptions\header.hbs
\actions\userlinking\notificationemail\body.hbs
\actions\userlinking\notificationemail\subject.hbs

Type Specific

The header and body content of specific authentication types (Facebook, Google etc). 

\types\<typeName>\header.hbs
\types\<typeName>\body.hbs

Default Template Tree

This is a simplified view (it doesn't include all of the actions or all of the types) of the standard template tree found in the main auth directory.

Template Tree
 

Overrides

Overrides let you customise the templates used by the worker. Your overrides are stored in the hbTemplateOverrideRoot set in the Worker Configuration Properties. This means your custom templates won't be overwritten when we release new versions of the worker, or during iCM patches.

The files you want to customise must have the same names as those being overridden. Their position in the tree determines how they are used.

While developing your override templates, set the worker's hbCacheTemplates property to false before you start. This will disable caching and let you see your changes without having to restart the API Server. Note that this disables caching on the templates the worker knows about, if you create new templates in new directories you'll need to resend the API Server config.  Remember to re-enable caching once you've finished.

Example Override Tree

This example globally overrides the login form and user consent templates, and overrides the body template and consent templates for all providers of the the Facebook type on a named subsite.

Override Tree
 

In most cases, if all you want to do is override the body.hbs template of all providers of a given type on a named subsite (eg customise the iCMSiteUser login template on your intranet), create your new template in <overrideRoot>\named\<subsiteName>\types\<typeName>\body.hbs

Template Resolution

This table outlines the priority order in which the worker will look for overrides. Within each section the top path takes priority, with the default \templates\ directory checked last.

  • <overrideRoot> is the root set in the worker configuration
  • <subsiteName> in our standard Authentication template the name of the subsite making the call to renderLoginForm is passed as the value of namedTemplateOverrides, so name your directories in the overrideRoot after subsites
  • <typeName> is the provider type you want to override. All named providers of this type will use the override unless a specific <providerName> override is found first
  • <providerName> a named provider in your worker configuration of one of the base types (eg you have configured two providers of the Facebook type with different names)
PathTypeDescription
Top Level
<overrideRoot>\named\
<subsite>\loginform\
NamedOverrideI want to override the login form for a named subsite
<overrideRoot>\loginform\GlobalI want to override the login form globally
templates\loginform\TypeThe default, as supplied with the worker
Type Specific
<overrideRoot>\named\
<subsite>\<providerName>\types\<typeName>
NamedOverride + ProviderI want to override the template for a named provider of this type on a specific subsite
<overrideRoot>\named\
<subsite>\types\<typeName>\
NamedOverrideI want to override the template for all providers of this type on this subsite
<overrideRoot>\
<providerName>\types\<typeName>\
ProviderI want to override the template for a named provider of this type, whatever subsite it is used on
<overrideRoot>\types\<typeName>\GlobalI want to override the template for all providers of this type
templates\types\<typeName>\TypeThe default, as supplied with the worker
Actions
<overrideRoot>\named\
<subsite>\<typeName>\actions\
NamedOverride + ProviderI want to override the action template for all providers of this type using this action on a certain subsite
<overrideRoot>\named\
<subsite>\actions\
NamedOverrideI want to override the action template for all providers using this action on a certain subsite
<overrideRoot>\<typeName>\actions\ProviderI want to override the action template for all providers of this type type using this action
<overrideRoot>\actions\GlobalI want to override the action template for all providers using this action
templates\actions\TypeThe default, as supplied with the worker

Model

The following elements are available to use in your templates.

NameTypeDescription
actionUrlStringForm submission action URL
codeStringThe two-factor authentication code
providerObjectThe base provider properties, eg provider.providerDisplayName
provider.hbHeaderTemplatePathStringPath to the provider's header template. Passed to the renderTypeSpecificTemplate helper
provider.hbBodyTemplatePathStringPath to the provider's body template. Passed to the renderTypeSpecificTemplate helper
provider.paramsObjectProvider parameters taken from the settings in the worker configuration
typeTypeBaseThe type's TypeBase subclass. toString() prints the value of authType, eg "saml2"
authTypeAuthType (enum)Enum stating the auth type, eg "saml2"
authSessionObjectAll of the properties in the current Auth Sessions
workerConfigObjectAny worker.conf property
Last modified on July 04, 2024

Share this page

Facebook icon Twitter icon email icon

Print

print icon