Skip to content

Commit 0f18b33

Browse files
authored
Merge pull request #25 from mongodb-developer/rbac-improvements
Improvements in the RBAC instructions
2 parents 1ee957d + 1ed0b1b commit 0f18b33

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

docs/challenge/rbac.mdx

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ sidebar_position: 2
33
---
44

55
# 👐 RUN : RBAC Challenge
6-
:::tip
76

87
:::info
98
The provided scripts are incomplete. Replace all `<CODE_BLOCK>` with the correct code to complete the lab.
@@ -13,7 +12,13 @@ The provided scripts are incomplete. Replace all `<CODE_BLOCK>` with the correct
1312
Hint: Remember to add `--projectId {project_id}`
1413
Refer to the documentation: [atlas dbusers](https://www.mongodb.com/docs/atlas/cli/current/command/atlas-dbusers-create/) , [atlas customDbRoles](https://www.mongodb.com/docs/atlas/cli/current/command/atlas-customDbRoles-create/)
1514
:::
16-
### 1. Create a user for "MyNewCluster" database only.
15+
### 1. Create a user for "MyNewCluster" database with role-based access.
16+
17+
Create a new user with the built-in role `readWriteAnyDatabase` and the username and password below.
18+
19+
The user access should be scoped to the `myNewCluster` cluster. Use the `--scope` option.
20+
21+
Refer to the documentation: https://www.mongodb.com/docs/atlas/cli/current/command/atlas-dbusers-create/.
1722

1823
```python
1924
# Create a user:'myNewClusterAdmin', password:'myNewClusterAdminPass', role: 'readWriteAnyDatabase'
@@ -38,11 +43,30 @@ newClusterAdminPass = 'myNewClusterAdminPass'
3843
3944
### 2. Create a user with read-only access to the "salesDB" database.
4045
46+
Create a custom role named `salesRead` with read-only access to the `salesDB` database.
47+
48+
Refer to the documentation: [atlas customDbRoles](https://www.mongodb.com/docs/atlas/cli/current/command/atlas-customDbRoles-create).
49+
4150
```python
4251
#Create a role "salesRead" which access to read-only role to salesDB database
4352
!atlas customDbRoles create <CODE_BLOCK>
53+
```
4454

45-
#Create a user "salesReadUser" with password "salesReadPass" which has the "salesRead" role
55+
:::tip
56+
<details>
57+
<summary> Answer </summary>
58+
```python
59+
#Create a role "salesRead" which access to read-only role to salesDB database
60+
!atlas customDbRoles create salesRead --inheritedRole read@salesDB --projectId {project_id}
61+
```
62+
</details>
63+
:::
64+
65+
66+
Now, we will create a user `salesReadUser` with password `salesReadPass` which has the `salesRead` role.
67+
68+
69+
```python
4670
salesReadUser = 'salesReadUser'
4771
salesReadPass = 'salesReadPass'
4872
!atlas dbusers create <CODE_BLOCK>
@@ -52,9 +76,6 @@ salesReadPass = 'salesReadPass'
5276
<details>
5377
<summary> Answer </summary>
5478
```python
55-
#Create a role "salesRead" which access to read-only role to salesDB database
56-
!atlas customDbRoles create salesRead --inheritedRole read@salesDB --projectId {project_id}
57-
5879
#Create a user "salesReadUser" with password "salesReadPass" which has the "salesRead" role
5980
salesReadUser = 'salesReadUser'
6081
salesReadPass = 'salesReadPass'
@@ -65,6 +86,8 @@ salesReadPass = 'salesReadPass'
6586

6687
### 3. Test that "salesReadUser" cannot insert data into the "salesDB" database.
6788

89+
We will test that indeed `salesReadUser` can't write to the database.
90+
6891
```python
6992
# Get connection string
7093
connection = !atlas clusters connectionStrings describe MyNewCluster --projectId {project_id}

0 commit comments

Comments
 (0)