Reinforced securing of the audit
This guide describes how to configure Any for a reinforced audit security based on restrictive roles in ElasticSearch and MongoDB.
You can apply this configuration at the initial installation or on a base already in production.
Prerequisites
1. Database security
ElasticSearch and MongoDB must be in secure mode with authentication enabled:
- See the ElasticSearch documentation to enable security
- See the MongoDB documentation to enable authentication
2. Role separation
Important: to avoid any security bypass:
- The Any configuration manager must NOT be the DBA
- The account used by Any must have no administration role
- The DBAs create the users and roles, an administrator configures the Any settings
3. Native database audit
Enable the native audit logs to trace:
- The sign-in attempts of the Any account
- The changes of roles and users
- Any administrative action
4. Backup strategy
Regularly back up the data on an immutable support (e.g. S3 with Object Lock).
ElasticSearch 8.x and 9.x configuration
Role creation
This role restricts access to the audit index (read and add only, no change).
Role permissions:
| Level | Resource | Permissions | Explanation |
|---|---|---|---|
| Cluster | All | monitor | Cluster monitoring |
| Index | /.*(audit).*/ | read, create_doc, view_index_metadata, monitor, auto_configure, create_index | Audit: read + add only |
| Index | /~(.*(audit).*)/ | all | Other indexes: full rights |
Creation through API:
PUT _security/role/any_index_role
{
"cluster": ["monitor"],
"indices": [
{
"names": ["/.*(audit).*/"],
"privileges": [
"read", "create_doc", "view_index_metadata",
"monitor", "auto_configure", "create_index"
]
},
{
"names": ["/~(.*(audit).*)/"],
"privileges": ["all"]
}
]
}
Alternative: use Kibana Management → Security → Roles to create the role graphically.
User account creation
A standard account (without administration privileges) is used by Any.
Creation through API:
PUT _security/user/anyadmin
{
"full_name": "Any Administrator",
"password": "<secure_password>",
"roles": ["any_index_role"],
"email": "admin@example.com"
}
Alternative: use Kibana Management → Security → Users to create the user graphically.
Role assignment
If you create the user and the role separately:
POST _security/user/anyadmin/_roles
{
"roles": ["any_index_role"]
}
MongoDB configuration
Preparation
MongoDB uses 2 separate databases:
- any_audit: audit collections only
- any: business data
The roles must be created in the admin database (not in the business databases).
Role creation
This role restricts access: audit in read/add only, other collections in full access.
Role permissions:
| Database | Collections | Permissions | Explanation |
|---|---|---|---|
| any_audit | All | createCollection, listCollections, insert, find, createIndex | Audit: read + add only |
| any | All | find, insert, update, remove, createCollection, listCollections, dropCollection, createIndex | Business: full access |
Creation through mongosh:
use admin;
db.createRole({
role: "anyAdminRole",
privileges: [
{
resource: { db: "any_audit", collection: "" },
actions: ["createCollection", "listCollections", "insert", "find", "createIndex"]
},
{
resource: { db: "any", collection: "" },
actions: ["find", "insert", "update", "remove", "createCollection", "listCollections", "dropCollection", "createIndex"]
}
],
roles: []
});
User account creation
Creation through mongosh:
use admin;
db.createUser({
user: "anyadmin",
pwd: passwordPrompt(),
roles: [{ role: "anyAdminRole", db: "admin" }]
});
Role assignment (if separate)
use admin;
db.grantRolesToUser("anyadmin", [{ role: "anyAdminRole", db: "admin" }]);
Any configuration
Changing settings.json
Once the roles and users are created, configure Any to use them.
MongoDB:
{
"mongodb-data": {
"server": {
"uri": "mongodb://anyadmin:$decrypt(xxxxx)@localhost:27017",
"database": "any",
"database_protected": "any_audit"
}
}
}
Fields:
- uri: connection string with authentication (encrypted password)
- database: base for the business data
- database_protected: base for the audit
ElasticSearch:
{
"elastic-search-data": {
"server": {
"clusterid": "Any",
"rest_url": "https://localhost:9200",
"version": "9.1.2",
"user": "anyadmin",
"password": "$decrypt(xxxxx)"
}
}
}
Fields:
- rest_url: URL of the cluster (https protocol recommended)
- version: version of ElasticSearch
- user / password: credentials of the restricted account
To generate an encrypted password, see Generating encrypted passwords.
Installation
First installation
- Create the roles and users in ElasticSearch and MongoDB (see above)
- Configure
settings.jsonwith the new accounts - Start the Any installation
- On the audit configuration page, tick "Enable reinforced protection"
- Continue the installation
Required post-installation
The restricted ElasticSearch account cannot create the any_audits alias automatically. A DBA must do it manually.
Steps:
- Stop Any
- A DBA creates the alias:
POST _aliases
{
"actions": [
{ "add": { "index": "g_audits", "alias": "any_audits" } }
]
}
- Restart Any
Note: if you configured a different audit index, adapt the g_audits name.
Enabling on an existing base
To add the reinforced security on an Any already in production:
Steps
- Upgrade Any to the latest version (see Upgrade)
- Create the roles and users in ElasticSearch and MongoDB
- Stop Any
- Configure
settings.jsonwith the new accounts and the two MongoDB bases - In MongoDB admin, manually create the audit base:
use any_audit;
db.createCollection("g_audit");
- Export the current audit from the old base and import it into
any_audit - On the configuration page, tick "Enable reinforced protection"
- Manually create the ElasticSearch alias (see Required post-installation)
- Restart Any