Secrets management
Externalised secrets
Introduction
Section titled “Introduction”Configuration supports externalisation of secrets (i.e. passwords) eliminating the need for clear-text secrets in configuration files.
Secrets are available using the standard mechanism of property expansion using the scope secrets:
"${secrets.<impl-specific-name>}"Configuration
Section titled “Configuration”Since secrets management is part of the configuration subsystem, it must be configured separately. To allow maximum flexibility, configuration is done using environment variables which can be set in the application start script, injected by container management systems or configured on the application user account, depending on how the system is set up.
Different implementations require different configuration. Which implementation to use is specified using the following environment variable:
# Default (noop)FORTIFIED_SECRETS_IMPL=default
# Use built-in 'local' implFORTIFIED_SECRETS_IMPL=local
# Use custom implFORTIFIED_SECRETS_IMPL=fully.qualified.class.NameImplementations
Section titled “Implementations”The built-in local secrets management implementation provides decryption of secrets stored in configuration.
Secrets must be encrypted, Base64-encoded, and added to configuration manually. No automatic encryption is done since configuration is read-only.
Only AES encryption (key size 128/256) is supported.
An encrypted property has the following format (where "yR3v4....wgkR0=" is the Base64-encoded encrypted value):
"${secrets.yR3v4eyaB/L4lTtI1PgPetsuJmafmgBuSYjU904aXMwgkR0=}"To enable this implementation, set the following environment variable(s):
# Enable built-in 'local' implFORTIFIED_SECRETS_IMPL=local
# AES secretFORTIFIED_SECRETS_SECRET=my-secret
# AES keysize (optional, defaults to 128)FORTIFIED_SECRETS_KEY_SIZE=256For more information on how to encrypt secrets for use with this implementation, see: /use-cases/misc/encrypt-configuration-secrets/
OpenSSL
Section titled “OpenSSL”To decrypt a secret encrypted with OpenSSL, use the following configuration:
# Enable OpenSSL implFORTIFIED_SECRETS_IMPL=fortified.platform.config.secrets.OpenSSLSecretsScope
# AES secretFORTIFIED_SECRETS_SECRET=my-secretCustom
Section titled “Custom”It is possible to supply custom secrets management implementations.
Custom implementations are enabled by supplying the fully qualified class name of the implementation.
# Use custom implFORTIFIED_SECRETS_IMPL=fully.qualified.class.NameA custom implementation must implement the following interface available in platform-config-<version>.jar.
package fortified.platform.config.secrets;
public interface SecretsResolver { String resolve(String key);}The custom implementation class and all of its dependencies must also be available on the application class path.
Setting environment variables using power shell
Section titled “Setting environment variables using power shell”To set variables on Windows using power shell in terminal execute:
[Environment]::SetEnvironmentVariable('FORTIFIED_SECRETS_IMPL', 'local', [EnvironmentVariableTarget]::Machine)[Environment]::SetEnvironmentVariable('FORTIFIED_SECRETS_SECRET', 'Fortified', [EnvironmentVariableTarget]::Machine)
# AES keysize (optional, defaults to 128)[Environment]::SetEnvironmentVariable('FORTIFIED_SECRETS_KEY_SIZE', '256', [EnvironmentVariableTarget]::Machine)This will set required variables "machine-wide".