Skip to content

Commit ca26e14

Browse files
authored
DOC-634 | Wildcard access levels (#365)
* Fix typo * Formatting * Fix description and examples of how access levels are determined. * Apply to 3.10 and 3.11
1 parent bf79d22 commit ca26e14

File tree

12 files changed

+483
-234
lines changed

12 files changed

+483
-234
lines changed

site/content/3.10/components/web-interface/users.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ and their corresponding database access level for that user.
2525
![User Permissions](../../../images/userPermissions.png)
2626

2727
Please note that server access level follows from the access level on
28-
the database *\_system*. Furthermore, the default database access level
28+
the `_system` database. Furthermore, the default database access level
2929
for this user appear in the artificial row with the database name `*`.
3030

3131
Below this table is another one for the collection category access

site/content/3.10/develop/http-api/users.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ You should never manipulate the `_users` collection directly. The specialized
1616
endpoints intentionally have limited functionality compared to the regular
1717
Document API.
1818

19+
See [Managing Users](../../operations/administration/user-management/_index.md)
20+
for details and note that using wildcard database and collection access levels
21+
is discouraged.
22+
1923
{{< info >}}
2024
User management operations are not included in ArangoDB's replication.
2125
{{< /info >}}

site/content/3.10/operations/administration/user-management/_index.md

Lines changed: 146 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ menuTitle: User Management
44
weight: 25
55
description: >-
66
User management is possible in the web interface and in _arangosh_ in the
7-
contect of the `_system` database
7+
context of the `_system` database
88
archetype: chapter
99
---
1010
Authentication needs to be enabled on the server in order to employ user
@@ -36,7 +36,7 @@ service arangodb restart
3636
```
3737

3838
User management is possible in the [web interface](../../../components/web-interface/users.md)
39-
while logged on to the *\_system* database and in
39+
while logged on to the `_system` database and in
4040
[arangosh](in-arangosh.md), as well as via the
4141
[HTTP API](../../../develop/http-api/users.md).
4242

@@ -115,7 +115,7 @@ access levels. The access levels are *Administrate* and
115115
| update a user | Administrate |
116116
| update user access level | Administrate |
117117
| drop a user | Administrate |
118-
| shutdown server | Administrate |
118+
| shutdown server | Administrate |
119119

120120
To perform actions in a specific database (like creating or dropping collections),
121121
a user needs at least the following access level.
@@ -179,16 +179,16 @@ from the database access level in the `_system` database, it is
179179

180180
### Initial Access Levels
181181

182-
When a user creates a database the access level of the user for that database
182+
When a user creates a database, the access level of the user for that database
183183
is set to *Administrate*. The same is true for creating a collection, in this
184-
case the user get *Read/Write* access to the collection.
184+
case the user gets *Read/Write* access to the collection.
185185

186186
### Wildcard Database Access Level
187187

188188
With the above definition, one must define the database access level for
189189
all database/user pairs in the server, which would be very tedious. In
190-
order to simplify this process, it is possible to define, for a user,
191-
a wildcard database access level. This wildcard is used if the database
190+
order to simplify this process, it is possible to define a wildcard
191+
database access level for a user. This wildcard is used if the database
192192
access level is *not* explicitly defined for a certain database. Each new
193193
created user has an initial database wildcard of *No Access*.
194194

@@ -202,33 +202,52 @@ If you delete the wildcard, the default access level is defined as *No Access*.
202202

203203
The `root` user has an initial database wildcard of *Administrate*.
204204

205-
*Example*
205+
If a user has the access level *Access* or *Administrate* for the `_system`
206+
database but a lower wildcard database access level, then the `_system` database
207+
access level is granted for all databases that do not have an explicit
208+
access level defined.
209+
210+
See [Permission Resolution](#permission-resolution) for details.
211+
212+
**Example**
206213

207214
Assume user *JohnSmith* has the following database access levels:
208215

209-
| | access level |
210-
|------------------|--------------|
211-
| database `*` | Access |
212-
| database `shop1` | Administrate |
213-
| database `shop2` | No Access |
216+
| | Access level |
217+
|--------------------|--------------|
218+
| database `_system` | No Access |
219+
| database `shop1` | Administrate |
220+
| database `shop2` | No Access |
221+
| database `*` | Access |
214222

215-
This will give the user *JohnSmith* the following database level access:
223+
This gives the user *JohnSmith* the following database level access:
216224

225+
- database `_system`: *No Access*
217226
- database `shop1`: *Administrate*
218227
- database `shop2`: *No Access*
219228
- database `something`: *Access*
220229

221-
If the wildcard `*` is changed from *Access* to *No Access* then the
222-
permissions will change as follows:
230+
If the wildcard `*` is changed from *Access* to *No Access*, then the
231+
permissions change as follows:
223232

233+
- database `_system`: *No Access*
224234
- database `shop1`: *Administrate*
225235
- database `shop2`: *No Access*
226236
- database `something`: *No Access*
227237

238+
If the `_system` database access level is changed from *No Access* to
239+
*Administrate*, then the permissions change again for databases with no
240+
explicitly defined access level:
241+
242+
- database `_system`: *Administrate*
243+
- database `shop1`: *Administrate*
244+
- database `shop2`: *No Access*
245+
- database `something`: *Administrate*
246+
228247
### Wildcard Collection Access Level
229248

230-
For each user and database there is a wildcard collection access level.
231-
This level is used for all collections pairs without an explicitly
249+
For each user and database, there is a wildcard collection access level.
250+
This level is used for all collections of a database without an explicitly
232251
defined collection access level. Note that this includes collections
233252
which will be created in the future and for which no explicit access
234253
levels are set for a that user! Each new created user has an initial
@@ -239,93 +258,154 @@ If you delete the wildcard, the system defaults to *No Access*.
239258
The `root` user has an initial collection wildcard of *Read/Write* in every database.
240259

241260
When creating a user through
242-
[`db._createDatabase()`](../../../develop/javascript-api/@arangodb/db-object.md#db_createdatabasename--options--users)
243-
the access level of the user for this database will be set to *Administrate*
244-
and the wildcard for all collections within this database will be set to
245-
*Read/Write*.
261+
[`db._createDatabase()`](../../../develop/javascript-api/@arangodb/db-object.md#db_createdatabasename--options--users),
262+
the access level of the user for this database is set to *Administrate* and the
263+
wildcard for all collections within this database are set to *Read/Write*.
246264

247-
**Example**
265+
If a user has the access level *Access* or *Administrate* for the `_system`
266+
database but a lower wildcard database access level or wildcard collection
267+
access level, then the `_system` database access level is granted for all
268+
collections that do not have an explicit access level defined.
269+
270+
See [Permission Resolution](#permission-resolution) for details.
271+
272+
{{< security >}}
273+
It is recommended to use explicitly defined access levels for all databases and
274+
collections instead of wildcard grants to avoid accidentally granting more
275+
permissions than intended.
276+
{{< /security >}}
277+
278+
**Examples**
248279

249280
Assume user *JohnSmith* has the following database access levels:
250281

251-
| | access level |
252-
|--------------|--------------|
253-
| database `*` | Access |
282+
| | Access level |
283+
|--------------------|--------------|
284+
| database `_system` | No Access |
285+
| database `*` | Access |
254286

255-
and collection access levels:
287+
And the following collection access levels:
256288

257-
| | access level |
289+
| | Access level |
258290
|-----------------------------------------|--------------|
259291
| database `*`, collection `*` | Read/Write |
260292
| database `shop1`, collection `products` | Read-Only |
261293
| database `shop1`, collection `*` | No Access |
262-
| database `shop2`, collection `*` | Read-Only |
294+
| database `shop2`, collection `reviews` | No Access |
263295

264-
Then the user *doe* will get the following collection access levels:
296+
Then the user *JohnSmith* gets the following collection access levels:
265297

266298
- database `shop1`, collection `products`: *Read-Only*
267-
- database `shop1`, collection `customers`: *No Access*
268-
- database `shop2`, collection `reviews`: *Read-Only*
269-
- database `something`, collection `else`: *Read/Write*
299+
- database `shop1`, collection `customers`: *Read/Write*
300+
- database `shop2`, collection `reviews`: *No Access*
270301

271302
Explanation:
272303

273304
Database `shop1`, collection `products` directly matches a defined
274-
access level. This level is defined as *Read-Only*.
305+
collection access level and the database access level is higher
306+
than *No Access*, leading to *Read-Only* access for the collection.
275307

276308
Database `shop1`, collection `customers` does not match a defined access
277-
level. However, database `shop1` matches and the wildcard in this
278-
database for collection level is *No Access*.
309+
level. There is a wildcard collection access level of *No Access*, but it cannot
310+
lower the access level granted by the wildcard combination of database `*`,
311+
collection `*`, leading to *Read/Write* access for the collection.
312+
313+
Database `shop2` does not match a defined access level. However, the database
314+
matches the database wildcard access level of *Access*. The access level for all
315+
collections with no defined access level would be *Read/Write* because of the
316+
wildcard combination of database `*`, collection `*`, but the `reviews`
317+
collection has a defined access level of *No Access*, leading to no access for
318+
this collection.
279319

280-
Database `shop2`, collection `reviews` does not match a defined access
281-
level. However, database `shop2` matches and the wildcard in this
282-
database for collection level is *Read-Only*.
320+
Assume user *JohnSmith* has the following database access levels:
283321

284-
Database `something`, collection `else` does not match a defined access
285-
level. The database `something` also does have a direct matches.
286-
Therefore the wildcard is selected. The level is *Read/Write*.
322+
| | Access level |
323+
|--------------------|--------------|
324+
| database `_system` | Access |
325+
| database `shop2` | Administrate |
326+
| database `*` | No Access |
327+
328+
And the following collection access levels:
329+
330+
| | Access level |
331+
|------------------------------------------|--------------|
332+
| database `shop1`, collection `customers` | No Access |
333+
| database `shop1`, collection `*` | No Access |
334+
335+
Then the user *JohnSmith* gets the following collection access levels:
336+
337+
- database `shop1`, collection `products`: *Read-Only*
338+
- database `shop1`, collection `customers`: *No Access*
339+
- database `shop2`, collection `reviews`: *Read/Write*
340+
341+
Explanation:
342+
343+
Database `shop1`, collection `products` does not match a defined access
344+
level. There is a wildcard collection access level of *No Access*, but it cannot
345+
lower the access level granted via the `_system` database, leading to *Read-Only*
346+
access for the collection.
347+
348+
Database `shop1`, collection `customers` directly matches a defined
349+
collection access level. The database access level is higher than *No Access*
350+
but the explicitly defined collection access level of *No Access* leads to no
351+
access for the collection.
352+
353+
Database `shop2` has a defined access level of *Administrate*. No access level
354+
is defined for its collections, which is equal to a wildcard collection
355+
access level of *No Access*. However, the *Administrate* database access level
356+
leads to *Read-Write* access for all collections in the database, including the
357+
`reviews` collection.
287358

288359
### Permission Resolution
289360

290361
The access levels for databases and collections are resolved in the following way:
291362

292363
For a database "*foo*":
293-
1. Check if there is a specific database grant for *foo*, if yes use the granted access level
294-
2. Choose the higher access level of::
295-
- A wildcard database grant ( for example `grantDatabase('user', '*', 'rw'`)
296-
- A database grant on the `_system` database
297-
298-
For a collection named "*bar*":
299-
1. Check if there is a specific database grant for *bar*, if yes use the granted access level
300-
2. Choose the higher access level of::
301-
- Any wildcard access grant in the same database, or on `"*"` (in this example `grantCollection('user', 'foo', '*', 'rw')`)
302-
- The access level for the current database (in this example `grantDatabase('user', 'foo', 'rw'`)
303-
- The access level for the `_system` database
304-
305-
An exception to this are system collections, here only the access level for the database is used.
364+
1. Check if there is a specific database grant for *foo*.
365+
If yes, use the granted access level.
366+
2. Choose the higher access level of:
367+
- A wildcard database grant (like `grantDatabase('user', '*', 'rw')`).
368+
- A database grant on the `_system` database.
369+
370+
For a collection named "*bar*" in a database "*foo*":
371+
1. Check whether the effective access level for the database *foo* is higher than
372+
*No Access* (see above). If not, then you cannot access the collection *bar*.
373+
2. Check if there is a specific collection grant for *bar*.
374+
If yes, use the granted collection access level for *bar*.
375+
3. Choose the higher access level of:
376+
- A wildcard collection grant in the same database
377+
(like `grantCollection('user', 'foo', '*', 'rw')`).
378+
- A wildcard database grant (like `grantDatabase('user', '*', 'rw')`).
379+
- The access level for the current database (like `grantDatabase('user', 'foo', 'rw'`).
380+
- The access level for the `_system` database.
381+
382+
An exception to this are system collections, where only the access level for the
383+
database is used.
306384

307385
### System Collections
308386

309387
The access level for system collections cannot be changed. They follow
310388
different rules than user defined collections and may change without further
311-
notice. Currently the system collections follow these rules:
389+
notice. The system collections follow these rules:
312390

313-
| collection | access level |
314-
|-----------------------|--------------|
315-
| `_users` (in _system) | No Access |
316-
| `_queues` | Read-Only |
317-
| `_frontend` | Read/Write |
318-
| `*` | *same as db* |
391+
| Collection | Access level |
392+
|--------------------------------------|--------------|
393+
| `_users` (in the `_system` database) | No Access |
394+
| `_queues` | Read-Only |
395+
| `_frontend` | Read/Write |
396+
| `*` (default) | *based on the current database* |
319397

320398
All other system collections have access level *Read/Write* if the
321399
user has *Administrate* access to the database. They have access level
322400
*Read/Only* if the user has *Access* to the database.
323401

324-
To modify these system collections you should always use the
325-
specialized APIs provided by ArangoDB. For example
326-
no user has access to the *\_users* collection in the *\_system*
402+
To modify these system collections, you should always use the
403+
specialized APIs provided by ArangoDB. For example,
404+
no user has access to the `_users` collection in the `_system`
327405
database. All changes to the access levels must be done using the
328-
*@arangodb/users* module, the `/_users/` API or the web interface.
406+
[`@arangodb/users` module of the JavaScript API](in-arangosh.md),
407+
the [`/_api/user` HTTP API endpoints](../../../develop/http-api/users.md),
408+
or the web interface.
329409

330410
### LDAP Users
331411

site/content/3.10/operations/administration/user-management/in-arangosh.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ Also note that the server and database access levels are represented as
1818
- `ro`: for *Access*
1919
- `none`: for *No access*
2020

21-
This is again for backward compatibility.
21+
See [Managing Users](../_index.md) for details and note that using wildcard
22+
database and collection access levels is discouraged.
2223

2324
**Example**
2425

25-
Fire up *arangosh* and require the users module. Use it to create a new user:
26+
Start *arangosh* and require the users module. Use it to create a new user:
2627

2728
```js
2829
arangosh --server.endpoint tcp://127.0.0.1:8529 ...
@@ -66,15 +67,13 @@ and grant him access to it with `grantDatabase()`:
6667
This grants the user *Administrate* access to the database
6768
*testdb*. `revokeDatabase()` will revoke this access level setting.
6869

69-
**Note**: Be aware that from 3.2 onwards the `grantDatabase()` will not
70-
automatically grant users the access level to write or read collections in a
71-
database. If you grant access to a database `testdb` you will
72-
additionally need to explicitly grant access levels to individual
73-
collections via `grantCollection()`.
74-
75-
The upgrade procedure from 3.1 to 3.2 sets the wildcard database access
76-
level for all users to *Administrate* and sets the wildcard collection
77-
access level for all user/database pairs to *Read/Write*.
70+
{{< info >}}
71+
Using the `grantDatabase()` function does not necessarily grant users the
72+
access level to read or write to collections in a database. If you grant access
73+
to a database, you need to explicitly grant access levels to individual
74+
collections via `grantCollection()` unless a wildcard or `_system` database
75+
access level applies.
76+
{{< /info >}}
7877

7978
Before we can grant *JohnSmith* access to a collection, we first have to
8079
connect to the new database and create a collection. Disconnect `arangosh`

site/content/3.11/components/web-interface/users.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ and their corresponding database access level for that user.
2525
![User Permissions](../../../images/userPermissions.png)
2626

2727
Please note that server access level follows from the access level on
28-
the database *\_system*. Furthermore, the default database access level
28+
the `_system` database. Furthermore, the default database access level
2929
for this user appear in the artificial row with the database name `*`.
3030

3131
Below this table is another one for the collection category access

site/content/3.11/develop/http-api/users.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ You should never manipulate the `_users` collection directly. The specialized
1616
endpoints intentionally have limited functionality compared to the regular
1717
Document API.
1818

19+
See [Managing Users](../../operations/administration/user-management/_index.md)
20+
for details and note that using wildcard database and collection access levels
21+
is discouraged.
22+
1923
{{< info >}}
2024
User management operations are not included in ArangoDB's replication.
2125
{{< /info >}}

0 commit comments

Comments
 (0)