-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
grant db admin the auto user role with admin option #48949
grant db admin the auto user role with admin option #48949
Conversation
TODO: test this change against OSS postgres. I'm glad to see the e2e tests passed in AWS though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice find! change looks good to me.
Two questions:
- Is it possible to improve the performance by reducing number of sql calls per user connection? For example, maybe we can check if teleportAutoUserRole is already assigned to admin user with admin option (so 99% of time 1 call, 1% 3 calls). If not easy, we can leave it as it is since we already making too many calls. but i would like to improve when we can.
- How does this affect Redshift?
I agree this is a good idea, I'll do that
If by this you mean the issue: In redshift, they document this about granting roles https://docs.aws.amazon.com/redshift/latest/dg/t_role_assignment.html
But they also document that superusers are defined as those users with
Our auto-user provisioning for redshift involves creating the "teleport-auto-user" role and creating users which are granted that role. As for how this PR affects redshift: the syntax is supported and does essentially the same thing. I'll test it out to be sure - worst case there's some issue that causes a debug error log but otherwise doesn't break anything. |
@GavinFrazar See the table below for backport results.
|
@GavinFrazar the line here: https://github.com/gravitational/teleport/blob/v17.1.3/lib/srv/db/postgres/users.go#L433 stmt := fmt.Sprintf("grant role %q to %q WITH ADMIN OPTION", teleportAutoUserRole, adminUser) should be: stmt := fmt.Sprintf("grant %q to %q WITH ADMIN OPTION", teleportAutoUserRole, adminUser) I mean without the word "role" no ? |
🤦♂️ yes it should not have "role" in it, thank you for mentioning it. |
Changelog: Fixed a permissions error with Postgres database user auto-provisioning that occurs when the database admin is not a superuser and the database is upgraded to Postgres v16 or higher.
This PR fixes an issue I found where when RDS postgres on v15 or below is configured with auto user provisioning, and "teleport-admin" is not granted
rds_superuser
(orSUPERUSER
attribute in OSS), auto user provisioning breaks after upgrading the instance to v16 or higher:tsh db connect error:
connecting as the admin manually and trying to grant the auto user role to another user:
I tested this manually by upgrading my RDS instance v14 -> v16, and observed that it breaks auto user provisioning.
Had we always granted the auto user role to ourselves, then the upgrade to v16 would not break anything - hence this PR
for more details, see my comment here explaining the nuances of v16+ postgres and RDS: #48897 (comment)