mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-09 03:25:59 +08:00
MongoDB supports non-root users (#1684)
* MongoDB supports non-root users Signed-off-by: skiffer-git <44203734@qq.com> * Update component.go * Update env-template.yaml * Update docker-compose.yml * Update environment.sh * Update openim.yaml * Update mongo-init.sh --------- Signed-off-by: skiffer-git <44203734@qq.com> Co-authored-by: Xinwei Xiong <3293172751@qq.com>
This commit is contained in:
+12
-6
@@ -12,15 +12,21 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
mongo -- "$MONGO_INITDB_DATABASE" <<EOF
|
||||
db = db.getSiblingDB('admin')
|
||||
set -e
|
||||
|
||||
mongosh <<EOF
|
||||
use admin
|
||||
db.auth('$MONGO_INITDB_ROOT_USERNAME', '$MONGO_INITDB_ROOT_PASSWORD')
|
||||
|
||||
|
||||
db = db.getSiblingDB('$MONGO_INITDB_DATABASE')
|
||||
db.createUser({
|
||||
user: "$MONGO_USERNAME",
|
||||
pwd: "$MONGO_PASSWORD",
|
||||
user: "$MONGO_OPENIM_USERNAME",
|
||||
pwd: "$MONGO_OPENIM_PASSWORD",
|
||||
roles: [
|
||||
{ role: 'root', db: '$MONGO_INITDB_DATABASE' }
|
||||
// Assign appropriate roles here
|
||||
{ role: 'readWrite', db: '$MONGO_INITDB_DATABASE' }
|
||||
]
|
||||
})
|
||||
});
|
||||
EOF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user