Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enabling user authentication in MongoDB

 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you're just starting out with MongoDB e.g. playing with it on your home PC, you don't need to worry about setting up database users etc, because authentication is disabled by default.

But once you start thinking about building an application with MongoDB, you'll probably need to think about which users should be able to read/write to which databases/collections. For example, ordinary users should probably only be able to read/write certain collections in a given database, while your application admin would need to be able to do things like create collections and create indexes etc in the application database.

Coming from an RDBMS background, I found MongoDB's user set-up a bit confusing, so I put together a blog post on how to set up a couple of users for an application database, where some users can only read/write in a specific database/collection.

It's just a learning example, so don't rely on this for your production systems - always rely on the MongoDB documentation for real-world applications! But it might help you to get started with MongoDB's approach to user permissions etc.
 
Johnc Smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To enable user authentication in MongoDB start MongoDB with --auth option
MongoDB requires all users to authenticate themselves. There are many authentication mechanism:
  • db.auth() method provide authentication
  • Kerberos Authentication mechanism system
  • SCRAM-SHA-1
  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic