@@ -4,80 +4,40 @@ Create a User Administrator
4
4
5
5
.. default-domain:: mongodb
6
6
7
- In a MongoDB deployment, users with either the
8
- :authrole:`userAdmin` or :authrole:`userAdminAnyDatabase` roles are
9
- *effective* administrative "superusers". Users
10
- with either of these roles can create and modify any other users and can
11
- assign them any privileges. The user also can grant *itself* any
12
- privileges. In production deployments, this user should have *no other
13
- roles* and should only administer users and privileges.
14
-
15
- This should be the first user created for a MongoDB deployment. This
16
- user can then create all other users in the system.
17
-
18
- .. important:: The :authrole:`userAdminAnyDatabase` user can grant
19
- itself and any other user full access to the entire MongoDB
20
- instance. The credentials to log in as this user should be
21
- carefully controlled.
22
-
23
- Users with the :authrole:`userAdmin` and
24
- :authrole:`userAdminAnyDatabase` privileges are not the same as the
25
- UNIX ``root`` superuser in that this role confers **no additional
26
- access** beyond user administration. These users cannot perform
27
- administrative operations or read or write data without first
28
- conferring themselves with additional permissions.
29
-
30
- The :authrole:`userAdmin` allows a user the ability to gain
31
- :authrole:`userAdminAnyDatabase`, and so for the ``admin`` database
32
- **only** these roles are effectively the same.
33
-
34
- Create a User Administrator
35
- ---------------------------
36
-
37
- 1. Connect to the :program:`mongod` or :program:`mongos` by either:
38
-
39
- - Authenticating as an existing user with the :authrole:`userAdmin`
40
- or :authrole:`userAdminAnyDatabase` role.
41
-
42
- - Authenticating using the :ref:`localhost exception
43
- <localhost-exception>`. When creating the first user in a
44
- deployment, you must authenticate using the :ref:`localhost exception
45
- <localhost-exception>`.
46
-
47
- #. Switch to the ``admin`` database:
48
-
49
- .. code-block:: javascript
50
-
51
- db = db.getSiblingDB('admin')
52
-
53
- #. Add the user with either the :authrole:`userAdmin` role or
54
- :authrole:`userAdminAnyDatabase` role, and only that role, by issuing
55
- a command similar to the following, where ``<username>`` is the
56
- username and ``<password>`` is the password:
57
-
58
- .. code-block:: javascript
59
-
60
- db.addUser( { user: "<username>",
61
- pwd: "<password>",
62
- roles: [ "userAdminAnyDatabase" ] } )
63
-
64
- To authenticate as this user, you must authenticate against the
65
- ``admin`` database.
7
+ Overview
8
+ --------
9
+
10
+ The user administrator creates users and creates and assigns roles. The
11
+ user administrator can grant any privilege in the database and can create
12
+ new ones. In a MongoDB deployment, create the user administrator as the
13
+ first user. Then let this user create all other users.
14
+
15
+ To support creation of user administrators, MongoDB provides the
16
+ :authrole:`userAdmin` and :authrole:`userAdminAnyDatabase` roles, both of
17
+ which grant :ref:`actions <security-user-actions>` specific to user and
18
+ role management and confer no additional privileges, in keeping with the
19
+ policy of :term:`least privilege`.
20
+
21
+ Carefully control these roles. A user with either of these roles can grant
22
+ *itself* additional privileges. Specifically, a user with the
23
+ :authrole:`userAdmin` role can grant itself any privilege in the database.
24
+ A user assigned either the :authrole:`userAdmin` role on the ``admin``
25
+ database or the :authrole:`userAdminAnyDatabase` can grant itself any
26
+ privilege *in the system*.
66
27
67
28
.. _localhost-exception:
68
29
69
- Authenticate with Full Administrative Access via Localhost
70
- ----------------------------------------------------------
30
+ Localhost Exception
31
+ -------------------
71
32
72
- If there are no users for the ``admin`` database, you can connect with
73
- full administrative access via the localhost interface. This bypass
74
- exists to support bootstrapping new deployments. This approach is
75
- useful, for example, if you want to run :program:`mongod` or
76
- :program:`mongos` with authentication before creating your first user .
33
+ The localhost exception lets you connect *with* administrative access to an
34
+ authentication-enabled :program:`mongod` or :program:`mongos` prior to
35
+ creating your first user on the ``admin`` database. The exception applies *if*
36
+ there are no users on the ``admin`` database. The bypass exists to support
37
+ bootstrapping new deployments .
77
38
78
- To authenticate via localhost, connect to the :program:`mongod` or
79
- :program:`mongos` from a client running on the same system. Your
80
- connection will have full administrative access.
39
+ To use the exception, connect to the :program:`mongod` or :program:`mongos`
40
+ from a client running on the same system.
81
41
82
42
To disable the localhost bypass, set the
83
43
:parameter:`enableLocalhostAuthBypass` parameter using
@@ -87,20 +47,16 @@ To disable the localhost bypass, set the
87
47
88
48
mongod --setParameter enableLocalhostAuthBypass=0
89
49
90
- .. note::
50
+ Prerequisites
51
+ -------------
91
52
92
- For versions of MongoDB 2.2 prior to 2.2.4, if :program:`mongos` is
93
- running with :setting:`keyFile`, then all users connecting over the
94
- localhost interface must authenticate, even if there aren't any users
95
- in the ``admin`` database. Connections on localhost are not correctly
96
- granted full access on sharded systems that run those versions.
53
+ .. include:: /includes/access-create-user.rst
97
54
98
- MongoDB 2.2.4 resolves this issue.
55
+ A user with either the :authrole:`userAdmin` or
56
+ :authrole:`userAdminAnyDatabase` role, or authenticated using the
57
+ :ref:`localhost exception <localhost-exception>`, has those privileges.
99
58
100
- .. note::
59
+ Procedure
60
+ ---------
101
61
102
- In version 2.2, you cannot add the first user to a sharded cluster
103
- using the ``localhost`` connection. If you are running a 2.2
104
- sharded cluster and want to enable authentication, you must deploy
105
- the cluster and add the first user to the ``admin`` database before
106
- restarting the cluster to run with :setting:`keyFile`.
62
+ .. include:: /includes/steps/add-user-administrator.rst
0 commit comments