mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-01 21:52:02 +08:00
* Organize docs guide sections chronologically This change aims to make docs navigation easier by organizing some docs sections according to the sequence of steps a user would take to set up Teleport. The current docs organization uses a variety of categories and schemes to organize the docs. For example, there is a "Home" section that includes the Changelog, Installation page, and Getting Started guides; a "Setup" section that includes references and admin guides; and edition-specific sections (Enterprise, Cloud). For a user who is setting up Teleport--or who has already done some setup work and wants more advanced instructions--it's difficult to know where in the docs to find the right information. This change organizes our how-to guides into the following categories that describe the process of setting up Teleport: - Try out Teleport - Deploy a Cluster (including choosing an edition) - Configure Access (including SSO, RBAC, and Access Requests) - Manage your Cluster (admin guides, operations, etc.) - Use Teleport (this section already exists) I moved the Reference section after this chronology, since users can access the reference guides anywhere in the setup process. As part of the change, I have also moved the content from the "Enterprise" and "Cloud" sections into "Deploy a Cluster", since this content has to do with how to deploy a specific edition of Teleport. Note that this change does _not_ attempt to reorganize our protocol-specific sections. While adding resources is part of the Teleport setup process, we have a lot of content in our protocol-specific sections, and moving it all into a single section related to adding resources to a cluster would (a) exceed the maximum depth for subsections in the nav bar and (b) cause more confusion than it alleviates. * Respond to PR feedback - Create a "Compliance Frameworks" section of "Configure Access" with the FedRAMP and SOC 2 guides - Rename "Use Teleport" to "Connect your Client" - Move the database GUI client guide into "Connect your Client" * Add redirects * Fix linter issues
138 lines
4.3 KiB
Plaintext
138 lines
4.3 KiB
Plaintext
---
|
|
title: Database Access Access Controls
|
|
description: Role-based access control (RBAC) for Teleport Database Access.
|
|
---
|
|
|
|
# Database Access Role-Based Access Control
|
|
|
|
Role-based access control (or RBAC, for short) allows administrators to set up
|
|
granular access policies for databases connected to Teleport.
|
|
|
|
An example of a policy could be, *"database administrators have access to
|
|
everything, QA team and engineers have full access to staging databases, and
|
|
engineers can gain temporary access to the production database in case of
|
|
emergency"*.
|
|
|
|
For a more general description of Teleport roles and examples see [RBAC](../access-controls/introduction.mdx), as
|
|
this section focuses on configuring RBAC for Database Access.
|
|
|
|
## Role configuration
|
|
|
|
Teleport's "role" resource provides the following instruments for restricting
|
|
database access:
|
|
|
|
```yaml
|
|
kind: role
|
|
version: v5
|
|
metadata:
|
|
name: developer
|
|
spec:
|
|
allow:
|
|
# Label selectors for database instances this role has access to.
|
|
#
|
|
# These will be matched against the static/dynamic labels set on the
|
|
# database service.
|
|
db_labels:
|
|
environment: ["dev", "stage"]
|
|
|
|
# Database account names this role can connect as.
|
|
db_users: ["viewer", "editor"]
|
|
|
|
# Database names this role will be able to connect to.
|
|
#
|
|
# Note, this is not the same as the "name" field in "db_service", this is
|
|
# the database names within a particular database instance.
|
|
#
|
|
# Also note, this setting has effect only for PostgreSQL. It does not
|
|
# currently have any effect on MySQL databases/schemas.
|
|
db_names: ["main", "metrics", "postgres"]
|
|
```
|
|
|
|
It is possible to use wildcards to match any database names/users.
|
|
|
|
For example, the following role permits access to any database/user within a
|
|
production database except for the internal "postgres" database/user:
|
|
|
|
```yaml
|
|
kind: role
|
|
version: v5
|
|
metadata:
|
|
name: developer
|
|
spec:
|
|
allow:
|
|
db_labels:
|
|
environment: ["prod"]
|
|
db_users: ["*"]
|
|
db_names: ["*"]
|
|
deny:
|
|
db_users: ["postgres"]
|
|
db_names: ["postgres"]
|
|
```
|
|
|
|
<Admonition
|
|
type="note"
|
|
title="Deny Rules"
|
|
>
|
|
Deny rules will match greedily. In the example above, a database connection
|
|
attempting to use "postgres" database account (regardless of database instance
|
|
or database name) or "postgres" database name (regardless of database instance
|
|
or database account) will be rejected.
|
|
</Admonition>
|
|
|
|
## Database names
|
|
|
|
There's a distinction in how different database servers handle logical databases
|
|
which leads to a difference in how `db_names` role field is applied to a connection
|
|
attempt.
|
|
|
|
PostgreSQL supports multiple logical databases, and each logical database can
|
|
contain multiple schemas. In order to change to a different database, a user
|
|
disconnects from the current one and establishes a new connection. During a
|
|
PostgreSQL connection attempt, `db_names` field is checked against the name
|
|
of the logical database that the user is connecting to.
|
|
|
|
In MySQL a logical "database" and a "schema" are synonyms for each other, and
|
|
the scope of permissions a user has once connected is determined by the permission
|
|
grants set on the account within the database. As such, `db_names` role field
|
|
is not currently enforced on MySQL connection attempts.
|
|
|
|
## Template variables
|
|
|
|
Similar to other role fields, `db_*` fields support templating variables.
|
|
|
|
The `{{external.xyz}}` variables are replaced with values from external [SSO](../access-controls/sso.mdx)
|
|
providers. For OIDC, they will be expanded with a value of an "xyz" claim; for
|
|
SAML — with an "xyz" assertion value.
|
|
|
|
For example, here is what a role may look like if you want to assign allowed
|
|
database names from the user's Okta `databases` assertion:
|
|
|
|
```yaml
|
|
spec:
|
|
allow:
|
|
db_names: ["{{external.databases}}"]
|
|
```
|
|
|
|
The `{{internal.db_users}}` and `{{internal.db_names}}` variables permit sharing
|
|
allowed database accounts and names with remote clusters. They will be replaced
|
|
with the respective properties of a remote user connecting from a root cluster.
|
|
|
|
For example, suppose a user in the root cluster has the following role:
|
|
|
|
```yaml
|
|
spec:
|
|
allow:
|
|
db_users: ["postgres"]
|
|
db_names: ["postgres"]
|
|
```
|
|
|
|
The role on the leaf cluster can be set up to use the user's allowed database
|
|
accounts and names:
|
|
|
|
```yaml
|
|
spec:
|
|
allow:
|
|
db_users: ["{{internal.db_users}}"]
|
|
db_names: ["{{internal.db_names}}"]
|
|
```
|