Configure Themis with your MongoDB server

Themis is compatible with MongoDB in its 2.6.* versions.

Two solutions are offered to you in this respect:

  • Use the MongoDB image provided by ProMyze (see that link). If it is your case, you are not concerned by the instructions bellow.
  • Configure Themis with your MongoDB server

In the case, where you use your own MongoDB base, you should run the Themis Docker container with a set of variables of environment allowing to specify the login information to that base.

Here is the listing of the variables that may be found out:

- MONGO_ADDR: URL of the MongoDB server. Example :

- MONGO_PORT: MongoDB docking port. Example: 27017

- MONGO_DB: Name of the base to use. Example: themis-db

MONGO_USE_CREDENTIALS: By default true, indicate false only if there is no need of authentication for your database.

- MONGO_USER: Identifier for the access in reading/writing to the database. Example: user

- MONGO_PASSWORD: Password for the login user. Example: pass

- MONGO_AUTHENTICATION_DB: Database to use for authentication. Example: themis-db

- MONGO_AUTHENTICATION_MECHANISM: Mechanism of authentication to use: MONGODB-CR (default) or SCRAM-SHA-1.

Every environment variables, except MONGO_AUTHENTICATION_MECHANISM, are mandatory upon execution. You may leave null values, if for example authentication is not required.

Here are two examples of configuration of environment variables, to put in the Themis service of the docker-compose.yml file (if you use Compose to launch Themis).

Example 1: MongoDB server with authentication

      - MONGO_PORT=27017
      - MONGO_USER=user
      - MONGO_PASSWORD=pass
      - MONGO_DB=themis-db


Example 2: MongoDB server without authentication

Indicate the MONGO_USE_CREDENTIALS environment variable with the false value.

      - MONGO_PORT=27017
      - MONGO_DB=themis-db

For Themis launch, to check that the connection to the database has been properly done, you may open the Themis-Engine file of log. If the connection has properly happened, you would have to observe the following message:

$> tail -n 40 log/themis_engine.log
... [main] INFO  p.t.p.MorphiaDAO - ****************************************************
... [main] INFO  p.t.p.MorphiaDAO - ********* Successfully connected to MongoDB ********
... [main] INFO  p.t.p.MorphiaDAO - ****************************************************

A potential connection problem to your Mongo DB will appear in that file of log.

Was this article helpful?
2 out of 2 found this helpful



Please sign in to leave a comment.