Skip to content
Sven Kubiak edited this page Jul 27, 2018 · 8 revisions

mangoo I/O relies on one configuration file for your hole application. The YAML based file application.yaml file is located in the src/main/resources folder, along with all other files that are not Java classes. You can add and customize settings, simply by adding a value in the application.yaml, for example

application:
      name   : myValue

There is a number of default property values which configure a mangoo I/O application. See default values, for all configuration options and there default values.

Config values are accessed in your application with a dot-notation. If you have a config value like

application:
      minify:
           js    : true
           css   : true

this would be accessible by the following keys

application.minify.js
application.minify.css

To access configuration values you have two options for retrieving the Config class. You can either inject the Config class via constructor or member variable.

Injection via member variable

@Inject
private Config config;

Injection via constructor variable (recommended)

@Inject
private MyClass(Config config) {
    //do something
}

You can access a configuration value, either by a given key or predefined default keys from mangoo I/O.

config.getString("application.minify.js");
config.getString(Key.APPLICATION_MINIFY_JS);

Modes

By convention, mangoo I/O offers three configuration modes: dev, test and prod. The dev mode is automatically activated when you start your mangoo I/O application with the Maven plugin for local development.

mvn mangooio:run

The test mode is automatically activated when executing unit test and the prod mode is activated by default when no other mode is given. You can overwrite this programatically, by setting a system property

System.setProperty("application.mode", "dev");

or by passing a system property to the executable JAR

... -Dapplication.mode=dev

Mode specific configuration

You can create mode specific configuration by prefixing a configuration value.

default:
    application:
        host       : localhost
        port       : 8080

test:
    application:
        port       : 10808

dev:
    application:
        port       : 2342

If no mode specific configuration is available, mangoo I/O will look up the default configuration. If mangoo I/O finds a environment specific value (e.g. dev.application.port), the value will overwrite the default value (e.g. default.application.port).

In other words, by convention all default values are for the prod mode and will be overwritten, when a mode specific value is found.

Encrypted values

All configuration values in the application.yaml configuration file can be encrypted using AES256 encryption. The values will be decrypted once the application starts an will be kept decrypted in-memory as long as the application runs.

In order to use encryption of config values you need a masterkey (Password) which has to reside outside of the application. Because it does not make sense to have the encrypted values a long with the passowrd in one file.

The masterkey needs to be either retrieved from a file, which can be setup in your application.yaml, or directly passed to the application via a JVM argument.

application:
    masterkeyfile: /path/to/masterkey/pwd.txt 
... -Dmasterkey=mypassword

Either way, the master key has to be in plain text.

To place an encrypted value in the application.yaml you have to set the encryption value into a specific pattern, as follows:

application:
   db:
        username: cryptex[...]
        password: cryptex[...]

The value within the brackets has to be the AES encrypted value. Please note, that there is not "t" and the end as this is related to Cryptex.

It is recommended to use the build-in encryption functions to create the encrypted values, see admin interface tools page.

Default values

T his is an overview of the out-of-thebox configuration options for the application.yaml and their default values, if the properties are not configured in the application.yaml file.

Option name Description Default value
application.secret The application secret Random value
application.name The name of the application mangooio
application.controller The package name containing the application controllers controllers
application.language The default language of the application en
application.minify.js Wether to minify javascript assets or not false
application.minify.css Wether to minify stylesheet assets or not false
application.preprocess.less Enable LESS file preprocessing false
application.preprocess.sass Enable SASS file preprocessing false
application.masterkey Absolute path to the master key file used for encrypted configuraiont values
application.threadpool Number of threads in the ExecutionManager 10
application.admin.enable Enable or disable the administrative /@admin URL false
application.admin.username The username for all administrative URLs
application.admin.password The password for all administrative URLs as JBcrypt hashed value
application.jwt.signkey The key used to sign the Json Web Token
application.jwt.encryptionkey The key used to encrypt the Json Web Token The application secret
application.jwt.encrypt Whether to encrypt the Json Web Token or not false
application.headers.xssprotection Header for XSS protection 1
application.headers.xcontenttypeoptions Header for X-ContentType options nosniff
application.headers.xframeoptions Header X-Frame options DENY
application.headers.refererpolicy Header for Referer Policy no-referrer
application.headers.server Header for server identity Undertow
application.headers.contentsecuritypolicy Header for Content Security Policy -
connector.ajp.host The host of the AJP connector
connector.ajp.port The port of the AJP connector
connector.http.host The host of the HTTP connector
connector.http.port The port of the HTTP connector
cookie.version Sets the version of a session cookie 0
cookie.name The name of the session cookie $application.name-MANGOOIO-SESSION
cookie.expires The time in seconds when the session expires 86400
cookie.encrypt Whether to encrypt the session cookie or not false
cookie.secure Whether to set the secure flag for the session cookie or not false
cache.cluster.enable Whether to enable or disable clustered cache configuration false
cache.cluster.url The URL of the clustered cache configuration
auth.cookie.name The name of the authentication cookie $application.name-MANGOO-AUTH
auth.cookie.expire The time in seconds how long the user stays logged in even is the browser is closed 3600
auth.cookie.remember.expire The time in seconds how long the user stays logged in if remember is set with true when logging in 1209600
auth.cookie.encrypt Whether to encrypt the authentication cookie or not false
auth.cookie.version Sets the version of an authentication cookie 0
auth.cookie.secure Whether to set the secure flag for the auth cookie or not false
auth.login.redirect The URL a user is redirected when not logged in
auth.lock Number of failed login attempts after which the user account is locked for 60 minutes 10
scheduler.autostart Wether to autostart the scheduler or not true
scheduler.package The package containing the quartz scheduler jobs jobs
smtp.host The host of your SMTP server localhost
smtp.port The port of your SMTP server 25
smtp.username The username of your SMTP server
smtp.password The password of your SMTP server
smtp.from The default SMTP from address mangoo I/O application [email protected]
smtp.ssl Wether or not to use SSL with your SMTP server false
undertow.maxentitysize The maximum limit of an entity size in byte 4194304

JVM arguments

mangoo I/O offers the option to pass any configuration value as JVM arugment. In order to use this functionality, you need to set a specific value at the property in the application.yaml configuration file. See the following example:

application:
             foo:
                 bar: ${arg} 

This will tell mangoo I/O to look for a JVM argument in the form of

-Dapplication.foo.bar=foobar

Retrieving a config value from a JVM argument will overwrite any other configuration value, as the JVM arguments have the highest priority.

Custom configuration

If you require a custom configuration for quartz inside mangoo I/O you can use the application.yaml to pass any option to quartz. Simply add the configuration option with the appropriate prefix org.quartz.

org:
    quartz:
        jobStore:
            class: com.novemberain.quartz.mongodb.MongoDBJobStore
            mongoUri: mongodb://localhost:27017
            dbName: quartz

Check out the Quartz Scheudler configuration documentation for more information.