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:
skiffer-git
2024-01-04 20:50:29 +08:00
committed by GitHub
parent d3047d73b6
commit 6764fa5e70
7 changed files with 47 additions and 31 deletions
+12 -6
View File
@@ -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