Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Authentication

kchodorow edited this page Aug 28, 2012 · 5 revisions

Note: authenticating is only required if you're using MongoDB with authentication enabled.

Usage

http://localhost:27080/dbname/_authenticate

Description

Authenticates a connection. Authentication is required before sending any reads or writes to a database started with --auth or --keyFile.

Once a connection is authenticated, it will remain authenticated until it is closed. Thus, reads and writes can be run normally.

Request Types

POST

Arguments

Required arguments:

  • username=username (string)
  • password=password (string)

Optional arguments:

None.

Return Values

On success:

{"ok" : 1}

On failure, an error message will be returned.

Example

Logging into the foo database.

$ curl --data 'username=someUser&password=mySecretPassword' 'http://localhost:27080/foo/_authenticate'
{"ok" : 1}
$ # now this will work:
$ curl --data 'docs=[{"x":1}]' 'http://localhost:27080/foo/bar/_insert'
$ # this will not (wrong database):
$ curl --data 'docs=[{"x":1}]' 'http://localhost:27080/baz/bar/_insert'
Clone this wiki locally