Skip to content
Sven Kubiak edited this page Aug 15, 2019 · 8 revisions

mangoo I/O relies on one configuration file for your application which is based on Jodd Props. The properties based config.props 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 by simply adding a value in the config.props file, 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
        minify.css = true

this would be accessible by the following keys in your application

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.

[application]
	connector.host = localhost
    connector.port = 8080

[application<test>]
	connector.host = localhost
    connector.port = 10808

[application<dev>]
	connector.host = localhost
    connector.port = 10909

By default mangoo I/O uses sections for mode specific configuration. If no mode specific value is found, mangoo I/O will lookup the default configuration.

Encrypted values

All configuration values in the config.props file can be encrypted using public/private key 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 generate a public/private key pair. This can be done via the mangoo I/O administrative backend which offers configuration tools.

Having generated a keypair you can encrypt your config values via the administrative interface and set them in your configuration file accordingly.

The private key for decryption needs to be either set via a JVM argument referencing a absolute file path.

... -Dapplication.privatekey=/path/to/privatekey

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

[application]
	db.username = cryptex{...}
    db.password = cryptex{...}

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

This 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.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.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.admin.secret The secret for 2FA for administrative access
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
cache.cluster.enable Whether to enable or disable clustered cache configuration false
cache.cluster.url The URL of the clustered cache configuration
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
smtp.debug Wether or not to use debug mode for your SMTP server false
smtp.plaintexttls Wether to use plaintext TLS for your SMTP server false
smtp.starttls Wether to use STARTTLS for your SMTP server true
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 config.props 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
org.quartz.jobStore.uri = mognodb://localhost:27017
org.quartz.jobStore.dbName = quartz

Check out the Quartz Scheudler configuration documentation for more information.