Skip to main content
Skip table of contents

Enable MongoDB Authentication

The Cantara Integration Platforms provides support for NoSQL datastores that enable detail transaction history logging. This is especially useful when debugging integration issues, mobile applications and to provide detail audit information when required. As of version 6.0.0, Cantara supports MongoDB and Google Cloud Firestore system. Further cloud based solutions will be added in the future. For MongoDB, it is required that authentication be enabled as sensitive business data may be stored in the transaction history. By default, MongoDB deploys with authentication disabled. This guide provides a recommended configuration to ensure that authentication is activated. Please refer to MongoDB documentation for further details and alternative configuration options.

Step-by-step guide

  1. Start MongoDB without authentication.
  2. Connect to the server using the mongo shell

    TEXT
    $ mongo mongodb://<host>:<port>
  3. Change the current database to admin

    TEXT
    > use admin
  4. Create the administration user account. In this example the username is mongoadmin and the password is MySecret

    JS
    > db.createUser(
      {
        user: "mongoadmin",
        pwd: "MySecret",
        roles: [{ role: "userAdminAnyDatabase", db: "admin" }]
      }
    )
  5. Disconnect from the mongo shell
  6. Open the MongoDB configuration file in your preferred editor. On linux this is generally found at /etc/mongod.conf. On Windows the default path is <InstallPath>/bin/mongod.cfg.
  7. Enable authentication by changing the authorization to "enabled"

    YML
    security:
      authorization: "enabled"
  8. Restart the MongoDB service
  9. Connect to the server using the mongo shell with the mongoadmin user

    BASH
    $ mongo mongodb://<host>:<port> -u mongoadmin -p 'MySecret' --authenticationDatabase 'admin'
  10. Create the user account for Cantara. As Cantara automatically creates the required database with for the farm you should provide any database rights.

    JS
    > use admin
    > db.createUser(
      {
        user: "cantara",
        pwd: "MyOtherSecret",
        roles: [{ role: "readWriteAnyDatabase", db: "admin" }]
      }
    )
    
    NOTE: authentication can also be performed from within the MongoDB shell using the db.auth() function:
    
    > db.auth('mongoadmin', 'MySecret')

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.