The MongoDB data source uses the MongoDB service to store and retrieve information.
The Curity Identity Server is shipped with an initialization script for MongoDB. It contains the collection definitions and indexes needed for a standard Curity Identity Server setup.
The collection definitions are found in the installation at <IDSVR>/etc/mongo-create_database.js. Even if MongoDB allows on the fly creation of databases and collections, to benefit from indexes and optimized query performance, make sure it is executed on the target database before starting to use the data-source (plugin).
<IDSVR>/etc/mongo-create_database.js
Multi-tenancy is supported out of the box for MongoDB, there is nothing to configure at data source level. Read more about multi-tenancy and how to configure it at authentication profile level.
The Curity Identity Server relies on external maintenance. Therefore it is important to setup janitor procedures before going into production. However, the following collections are automatically maintained and cleaned up thanks to MongoDB builtin data expiration mechanism.
Each item in these collections includes a deletableAt field containing the timestamp after which the item can be deleted. Its value is set to the item’s expiration timestamp, added with a retain duration. This retain duration is configurable per collection and defines the amount of time, in seconds, that an item should be kept in the database after it is considered expired (e.g. for audit purposes). Therefore, it can be used with the MongoDB TTL indexes feature, which automatically deletes items that are no longer needed. Note that this automatic removal mechanism is automatically enabled by Curity Identity Server, a default configured for each item type.
deletableAt
The MongoDB data source manages account and credential as two separate entities, which means that the data source can be used for standalone credential storage.
By default, the query used to retrieve credential data checks the account status, and no data is returned for inactive accounts. In such cases, the credential verification done by the Curity Identity Server always fails.
The MongoDB data source configuration model defines the following operation aspects:
MongoDB uses causally consistent client sessions, In order for the Curity Identity Server to behave correctly, it needs the four guarantees provided by MongoDB: Read own writes, Monotonic reads, Monotonic writes, Writes follow reads.
For that reason, it is highly recommended that the MongoDB data source is configured with Read and Write concerns set to majority. This can be done by adding query string options to the Connection String as follow:
mongodb://localhost:27047/curity?w=majority&readConcernLevel=majority