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

Ability to select database roles for auto-user-provisioning database session #35566

Closed
2 of 3 tasks
greedy52 opened this issue Dec 8, 2023 · 10 comments
Closed
2 of 3 tasks
Assignees
Labels
c-pl Internal Customer Reference database-access Database access related issues and PRs feature-request Used for new features in Teleport, improvements to current should be #enhancements

Comments

@greedy52
Copy link
Contributor

greedy52 commented Dec 8, 2023

What would you like Teleport to do?
When using auto-user provisioning feature, able to select a subset of allowed database roles for a database session, e.g.:

$ tsh db connect --db-name dev --db-role roleA -r roleB my-postgres

What problem does this solve?

A Teleport user may be granted multiple database roles for a select database. When Database Service provisions the user, it tries to assign all allowed database roles and will fail the session if any of the roles do not exist on the database.

If a workaround exists, please include it.

Teleport roles can be carefully crafted so that they only match the databases that have these roles preset in the database. Not feasible when no common database roles exist on a large number of databases.

Tasks

@greedy52 greedy52 added feature-request Used for new features in Teleport, improvements to current should be #enhancements database-access Database access related issues and PRs c-pl Internal Customer Reference labels Dec 8, 2023
@greedy52 greedy52 self-assigned this Dec 8, 2023
@greedy52 greedy52 changed the title Ability to select database roles for each auto-user-provisioning database session Ability to select database roles for auto-user-provisioning database session Dec 8, 2023
@Tener
Copy link
Contributor

Tener commented Dec 11, 2023

Database roles can also impose restrictions on a user, so I wonder if this feature should be opt-in? Otherwise user may sidestep the restrictions by skipping on a particular role.

@greedy52
Copy link
Contributor Author

Database roles can also impose restrictions on a user, so I wonder if this feature should be opt-in? Otherwise user may sidestep the restrictions by skipping on a particular role.

@Tener that's a good point. At least for MongoDB, authenticationRestrictions of a role can be used to control where login from/to. Can you specify "deny" roles for Postgres and MySQL? For example, on MySQL, I cannot revoke permissions from a role that doesn't already have the grant.

@Tener
Copy link
Contributor

Tener commented Dec 11, 2023

Hmm, looking into Postgres in particular: https://www.postgresql.org/docs/current/role-attributes.html

There is "connection limit", but I think a maximum one will be taken from multiple roles, so dropping a role can only limit you. A connection limit is not a very strong limitation anyway. Otherwise I think the roles in Postgres are designed to be "positive/allow", rather than "negative/deny".

@greedy52
Copy link
Contributor Author

Database roles can also impose restrictions on a user, so I wonder if this feature should be opt-in? Otherwise user may sidestep the restrictions by skipping on a particular role.

@jentfoo @r0mant what are your thoughts on this?

To maintain current behaviour and be safe, a new role option like select_db_roles: false can be added.

@jentfoo
Copy link
Contributor

jentfoo commented Dec 11, 2023

@greedy52 It may be difficult for customers to know when this option would be safe to use or not. I thought Database Permission Management was the path we were using to reduce this friction. When that RFD lands will this feature still be generally useful?

@greedy52
Copy link
Contributor Author

thought #33734 was the path we were using to reduce this friction. When that RFD lands will this feature still be generally useful?

@jentfoo

  • It will take a very long time before DB permission management can support more database types and more database object types. This feature is requested to be delivered soon.
  • This feature is still useful as many databases have pre-defined built-in roles. pg_read_all_data in PostgreSQL 14+, readAnyDatabase@admin in MongoDB, etc.

@jentfoo
Copy link
Contributor

jentfoo commented Dec 11, 2023

If we want to introduce this maybe naming the option user_selected_db_roles would be slightly better. It helps show that this now puts the role limitations within the users control.

It adds more options, but if db roles could be marked as required (and unable to be excluded using this option), then it could provide all the options an administrator needs to ensure deny actions are enforced. In documentation we would probably describe it as only necessary if the role is restricting access.

@greedy52
Copy link
Contributor Author

greedy52 commented Dec 11, 2023

@jentfoo Could you confirm that it would be a security concern if we do not add any additional flags at all, and just always allow a user to pick a subset of db roles assigned? Would rather be simple if possible. ( I assume the answer is yes its a concern but really want your opinion)

@r0mant
Copy link
Collaborator

r0mant commented Dec 12, 2023

@jentfoo @greedy52 @Tener I would not introduce any new flags/options for now and just let users select roles. Seems like this is a very "edge-casey" scenario to be worth of adding another role option.

@greedy52
Copy link
Contributor Author

@jentfoo @greedy52 @Tener I would not introduce any new flags/options for now and just let users select roles. Seems like this is a very "edge-casey" scenario to be worth of adding another role option.

Sounds good. I will add a note to the guide on this. Something like if any role is meant to restrict permissions, assign that role to every role in db_roles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-pl Internal Customer Reference database-access Database access related issues and PRs feature-request Used for new features in Teleport, improvements to current should be #enhancements
Projects
None yet
Development

No branches or pull requests

4 participants