【发布时间】:2016-12-08 13:10:33
【问题描述】:
我有一个node js 程序,它使用mongodb 作为它的数据库,看起来像这样:
show dbs
test
eas
use eas
show collections
nodeurls
nodes
users
在这个阶段,每个人都可以访问 mongo shell 并查看所有集合和其中的数据。但是,我想添加身份验证,以便有人首先必须对 mongo shell 进行身份验证,然后才能查看 mongo db 数据。
我发现了这个:https://docs.mongodb.com/manual/core/authentication/
并尝试使用db.auth() 方法,但我不明白这是如何完全工作的。
我假设我首先必须创建一个用户(我只想要一个用户用于 db mongo shell),然后用户需要进行身份验证?
对此的任何帮助将不胜感激!
【问题讨论】:
标签: node.js mongodb authentication