bigchaindb/k8s/mongodb/container/configure_mdb_users.template.js
Troy McConaghy abdd23f5a6 Problem: Source files contain no license info (#2455)
* Problem: Source files contain no license info

Solution: Add comments with SPDX license info to source files

* Python 3 files don't need # -*- coding: utf-8 -*-
2018-08-16 12:31:32 +02:00

57 lines
1.5 KiB
JavaScript

// Copyright BigchainDB GmbH and BigchainDB contributors
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
// Code is Apache-2.0 and docs are CC-BY-4.0
var configure_adminUser = CONFIGURE_ADMIN_USER;
var configure_bdbUser = CONFIGURE_BDB_USER;
var configure_mdbMonUser = CONFIGURE_MDB_MON_USER;
db = db.getSiblingDB("admin");
if (configure_adminUser) {
db.createUser({
user: "MONGODB_ADMIN_USERNAME",
pwd: "MONGODB_ADMIN_PASSWORD",
roles: [{
role: "userAdminAnyDatabase",
db: "admin"
},
{
role: "clusterManager",
db: "admin"
}
]
});
}
if (configure_adminUser && configure_bdbUser) {
db.auth("MONGODB_ADMIN_USERNAME", "MONGODB_ADMIN_PASSWORD");
db.getSiblingDB("$external").runCommand({
createUser: 'BDB_USERNAME',
writeConcern: {
w: 'majority',
wtimeout: 5000
},
roles: [{
role: 'clusterAdmin',
db: 'admin'
},
{
role: 'readWriteAnyDatabase',
db: 'admin'
}
]
});
}
if (configure_adminUser && configure_mdbMonUser) {
db.auth("MONGODB_ADMIN_USERNAME", "MONGODB_ADMIN_PASSWORD");
db.getSiblingDB("$external").runCommand({
createUser: 'MDB_MON_USERNAME',
writeConcern: {
w: 'majority',
wtimeout: 5000
},
roles: [{
role: 'clusterMonitor',
db: 'admin'
}]
});
}