The Curity Identity Server installation comes bundled with a UI Builder. It is a small toolkit that can be used when customizing the templates. It contains both a previewer that can serve the velocity templates without the server being running, as well as the source code for all templates and styles.
Prerequisites
The UI Builder is located in $INSTALL_DIR/misc/ui-builder. It contains a package.json with the Node.js dependencies. To install it simply return
$INSTALL_DIR/misc/ui-builder
package.json
$ npm install
This will install the node dependencies such as Webpack and Browsersync.
Webpack
Browsersync
Note
npm, the Node package manager, the npm Registry, and npm CLI is distributed with Node.js - which means that when you download Node.js, you automatically get npm installed on your computer.
Once development starts the UI Builder can be used as an integral part of the development process. For development in Linux or MacOS, the JRE provided with the Curity Identity Server can be used, by updating the environment file with the path to the installation. Alternatively, a local Java installation can be used.
environment
INSTALLATION_DIR=/path/to/curity/installation/release
The UI Builder can be used outside of the installation. When doing so update environment to point to the root of the Curity Identity Server installation.
For development in Windows, Java 17 or later must be installed.
Once installed the UI Builder provides a build system for the Sass and JavaScript source files. It also contains a previewer where all templates can be viewed. To start it run:
$ npm start
This will start the Java preview server, and also a Browser-Sync proxy and a file watcher. Any change made in the src directory of the UI Builder will immediately be compiled, and reflected in the browser via browser-sync.
src
If the command does not open a browser immediately go to the following address in your browser:
http://localhost:3000/listing
The structure of some screens are controlled by Velocity variables. A good example is the sms enter-otp screen. It is located under $UI_BUILDER/src/curity/templates/core/authenticator/sms/enter-otp/get.vm. To view it in the previewer open the main page at http://localhost:3000 and type sms in the search field.
$UI_BUILDER/src/curity/templates/core/authenticator/sms/enter-otp/get.vm
Fig. 185 Search screen in the previewer
This shows all templates related to the SMS authentication. Notice in the previewer, it doesn’t show any fragments or layouts since those aren’t entry points for screens. They are pulled in from the screens listed in the previewer.
Select the enter-otp/get.vm template from the list of sms templates, and you’ll see something similar to this:
enter-otp/get.vm
Fig. 186 SMS Enter OTP Template
This template is controlled via variables set by Curity when it loads the template. Inspect the source $UI_BUILDER/src/curity/templates/core/authenticator/sms/enter-otp/get.vm for the template and the following is present:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
... #if ($_allowRegistrationDuringLogin) <div class="center px3 mt4"> <p> #message("authenticator.sms.enter-otp.view.register-info") #if (!$_showInfoBeforeRegistration) ## The next thing the user will see is a login prompt (unless they've logged in before with ## an allowed authenticator), so we'll give them a bit of extra info before they're ## redirected. #message("authenticator.sms.enter-otp.view.register-info-login") #end </p> <a href="$nextPage" class="button button-grey button-fullwidth" role="button"> <i class="icon ion-ios-plus-outline inlineicon"></i>#message( "authenticator.sms.enter-otp.view.register-or-change") </a> </div> #else ...
One line 2 it checks if $_allowRegistrationDuringLogin is configured. If so it shows another section. To have the previewer show this, simply set that variable in the main screen and click apply.
$_allowRegistrationDuringLogin
Fig. 187 Set a context variable in the previewer
Then click the enter-otp/get.vm template again and see the difference
Fig. 188 SMS Enter OTP screen with registration enabled
The structure in the ui-builder source tree for templates mimics the deployment structure of Curity in $IDSVR_DIR/usr/share/templates.
ui-builder
$IDSVR_DIR/usr/share/templates
To override a template, create a copy in the overrides directory following the same structure. For example, to override the fragments/logo.vm
overrides
$UI_BUILDER/src/curity/images/your-logo.svg
$UI_BUILDER/src/curity/templates/overrides/fragments/logo.vm
1
<img class="login-logo" src="$_staticResourceRootPath/assets/images/your-logo.svg">
If you are running npm start then the previewer will be updated automatically. Visit the same page as above http://localhost:3000/authenticator/sms/enter-otp/get. Now you’ll notice that the logo is updated.
npm start
http://localhost:3000/authenticator/sms/enter-otp/get
Tip
You can view the core templates without overrides by adding ?area=core in the URL or by adding a velocity variable _area with the value core.
?area=core
_area
core
To view the non-overridden template add ?area=core to the query string: http://localhost:3000/authenticator/sms/enter-otp/get?area=core and only the core templates are shown.
http://localhost:3000/authenticator/sms/enter-otp/get?area=core
Just like with overrides you can create and view template-areas in the previewer. To create a template area simply create a folder with the name of your template area in the file:$UI_BUILDER/src/curity/templates/template-areas directory.
template-areas
Example
myarea
$UI_BUILDER/src/curity/templates/template-areas/myarea
fragments
logo.vm
Now visit http://localhost:3000/authenticator/sms/enter-otp/get again. You still see the override logo, not the template area logo. To view the template area add ?area=myarea to the url. Now the logo disappers.
override
?area=myarea
You can control which templates you see in the preview by the velocity variable _area. For example _area=myarea will show the templates under myarea without the need to add the query parameter. Adding a query parameter though, will override the velocity variable ?area=overrides will deem anything set on the velocity variable obsolete.
_area=myarea
?area=overrides
Warning
Do not update the core templates. Always copy them to overrides or an area in template-areas before editing. Updating core templates will cause issues when migrating between Curity versions.
You can change the language of the previewer by setting the _locale velocity variable or adding a query parameter ?locale=sv. Similar to the _areas velocity variable, the query parameter overrides the velocity variable (if it exists). The language shown by default is english.
_locale
?locale=sv
_areas
When running npm run build Webpack builds and copies all output to the build directory. The structure in the build directory mimics the structure in $IDSVR_DIR/usr/share. So you’ll find templates and webroot that you simply can copy into your Curity installation $IDSVR_DIR/usr/share structure.
npm run build
build
$IDSVR_DIR/usr/share
templates
webroot
Creating new files under template-areas, overrides or webroot won’t show up in the build directory if the previewer is running, so, to make sure everything is updated, always restart the build before copying the files to your installation.