When working with the configuration in XML form, the same XML can be re-used between different environments by parameterizing parts of the configuration. Values such as urls, and hostnames change between environments, and makes good sense to parameterize if using the XML configuration files.
Any value in the XML can be replaced with a parameter on the format #{variableName} or #{variableName | defaultValue}
#{variableName}
#{variableName | defaultValue}
The variable is then searched for in the environment of the Curity process. If the variable is not found in the environment and a default value exists, then that default value is used instead. Otherwise the configuration processing ends with an error.
<base-url>#{baseUrl}</base-url>
When the XML is placed in the init directory $IDSVR_HOME/etc/init it will be pre-processed before loaded into the running system. The pre-processor replaces all occurrence of parameters with the value found in the environment or with the default value. If a variable is not found in the process environment and does not have a default value, then the configuration cannot be loaded. If this happens during boot, Curity will stop and exit.
$IDSVR_HOME/etc/init
The parameterized configuration can be exported in XML format as well. It is possible to export the configuration with or without the parameters, using the appropriate flag for the idsvr command. When executing:
$ idsvr -d
then the configuration will be exported with the actual values instead of the parameters. On the contrary, when the configuration needs to be exported with the configuration parameters, then the -D flag should be used. As shown in the listing above, the -D would have been used to export the configuration parameter with the depicted format.
-D
Both -d and -D options can take a configuration path as an optional argument in order to export only this part of the configuration.
-d
For instance:
$ idsvr -D environments/environment/base-url
will only export the configuration segment for the path environments/environment/base-url and since the -D flag is used, then the configuration will contain the configuration parameters and will be similar to the listing below.
environments/environment/base-url
<config xmlns="http://tail-f.com/ns/config/1.0"> <environments xmlns="https://curity.se/ns/conf/base"> <environment> <base-url>#{baseUrl}</base-url> </environment> </environments> </config>
If a variable isn’t defined in the environment and a default value should be used, it is possible to set this using a pipe-like syntax. In particular, after the variable name, but inside the braces, add a pipe followed by the default value. As an example, assume that the baseUrl variable shown in Listing 336 above should have a default value of https://login.example.com. This could be achieved by altering the macro slightly to have a pipe after the name and then this default value as shown in the following, abbreviated listing:
baseUrl
https://login.example.com
<environment> <base-url>#{baseUrl | https://login.example.com}</base-url> </environment>
Instead of placing variable values in the process environment, the variables can be placed in startup.properties. This will have the same result as placing them in the environment. startup.properties takes precedence over the process environment.
startup.properties
Important
Parameterized configuration cannot be loaded using the REST or RESTCONF APIs. Currently it’s only possible to load these via the $IDSVR_HOME/etc/init directory.