Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] select db roles support for auto-provisioned db #36648

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Users created within the database will:

## Step 3/3. Connect to the database

(!docs/pages/includes/database-access/auto-user-provisioning/connect.mdx gui="MongoDB Compass"!)
(!docs/pages/includes/database-access/auto-user-provisioning/connect.mdx gui="MongoDB Compass" selectRoles="myCustomRole@db2"!)

## Next steps
- Learn more about MongoDB [built-in roles](https://www.mongodb.com/docs/manual/reference/built-in-roles/) and [User-Defined Roles](https://www.mongodb.com/docs/manual/core/security-user-defined-roles/).
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/database-access/reference/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ $ tsh db login --db-user=postgres --db-name=postgres example
| - | - |
| `--db-user` | The database user to log in as. |
| `--db-name` | The database name to log in to. |
| `--db-roles` | Comma-separated list of database roles to use for auto-provisioned user. If not provided, all database roles will be assigned. |

(!docs/pages/includes/db-user-name-flags.mdx!)

Expand All @@ -320,6 +321,8 @@ $ tsh db connect
$ tsh db connect example
# Provide database user and name to connect to.
$ tsh db connect --db-user=alice --db-name=db example
# Select a subset of allowed database roles.
$ tsh db connect --db-user=alice --db-name=db --db-roles reader example
```

<Admonition type="note" title="Note">
Expand All @@ -331,6 +334,7 @@ $ tsh db connect --db-user=alice --db-name=db example
| - | - |
| `--db-user` | The database user to log in as. |
| `--db-name` | The database name to log in to. |
| `--db-roles` | Comma-separated list of database roles to use for auto-provisioned user. If not provided, all database roles will be assigned. |

(!docs/pages/includes/db-user-name-flags.mdx!)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{ selectRoles="reader" }}

Now, log into your Teleport cluster and connect to the database:

```code
Expand All @@ -13,4 +15,18 @@ If using a GUI database client like {{gui}}, make sure to use your Teleport
username as the database username. `tsh db connect` will default to your
Teleport username automatically when connecting to a database with user
provisioning enabled.

When connecting to a leaf cluster database with user provisioning enabled, the
Database Service expects the database username to be
`remote-<your-teleport-username>-<root-cluster-name>`.
</Admonition>


To view the list of database roles that are allowed for each database, you can
use the command `tsh db ls -v`. By default, all database roles will be assigned
to your auto-provisioned database user. You can optionally select a subset of
the database roles with `--db-roles`:

```code
$ tsh db connect --db-name <database> --db-roles {{ selectRoles }} example
```
Loading