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

Allow users impersonating database service generate database certs #7024

Merged
merged 1 commit into from
May 25, 2021

Conversation

r0mant
Copy link
Collaborator

@r0mant r0mant commented May 25, 2021

This PR fixes the issue with users not being able to produce database certificates using tctl auth sign --format=db with remote proxy: #6937. The effect of this issue is that it is basically impossible to connect self-hosted databases to the Cloud currently.

Note: Here "database certificate" refers to the certificate that cluster admin uses to configure their self-hosted database instance with (signed with Teleport's host CA), not the client certificate issued during tsh db login.

Previously, we would only check for built-in roles Admin and Database which is both inflexible and, arguably, less secure. With this change I introduced a separate db_cert resource kind we're checking for "create" permission on: rather than checking for "create" on db_server as proposed in the linked ticket, I decided that having a separate resource makes more sense and also this is in-line with how host certificates RBAC is checked - which is conceptually similar.

Consequentially, I've updated our default admin and editor user roles and built-in Database role (used by database service agent) to include permission to generate these certificates.

Closes #6937. Needs backport to v6.

@r0mant r0mant added backport-required database-access Database access related issues and PRs labels May 25, 2021
@r0mant r0mant self-assigned this May 25, 2021
Copy link
Contributor

@russjones russjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bot.

lib/auth/auth_with_roles_test.go Show resolved Hide resolved
lib/auth/auth_with_roles_test.go Show resolved Hide resolved
@r0mant
Copy link
Collaborator Author

r0mant commented May 25, 2021

@klizhentas I've updated to check for impersonation permissions for builtin system roles instead, as we discussed. Since impersonation requires both users and roles, users wishing to generate db certs would need to add the following permission in their role:

impersonate:
  roles:
  - Db
  users:
  - Db

PTAL.

@r0mant r0mant merged commit fc4c18f into master May 25, 2021
@r0mant r0mant deleted the roman/sign branch May 25, 2021 21:11
@r0mant r0mant changed the title Check resource permission when generating database certs Allow users impersonating database service generate database certs May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-required database-access Database access related issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tctl auth sign --format=db doesn't work via proxy
6 participants