-
Notifications
You must be signed in to change notification settings - Fork 13
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
Make it possible to grant self created roles #298
Conversation
|
||
AddRoleMems(stmt->role, roleid, | ||
memberSpecs, memberIds, | ||
BOOTSTRAP_SUPERUSERID, true); |
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.
BOOTSTRAP_SUPERUSERID
Is that correct?
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.
It is taken from PG 16:
/*
* If the current user isn't a superuser, make them an admin of the new
* role so that they can administer the new object they just created.
* Superusers will be able to do that anyway.
*
* The grantor of record for this implicit grant is the bootstrap
* superuser, which means that the CREATEROLE user cannot revoke the
* grant. They can however grant the created role back to themselves with
* different options, since they enjoy ADMIN OPTION on it.
*/
if (!superuser())
{
...
AddRoleMems(BOOTSTRAP_SUPERUSERID, stmt->role, roleid,
memberSpecs, memberIds,
BOOTSTRAP_SUPERUSERID, &poptself);
PG 16 also also granting roles to themselves:
/*
* Because of the implicit grant above, a CREATEROLE user who creates
* a role has the ability to grant that role back to themselves with
* the INHERIT or SET options, if they wish to inherit the role's
* privileges or be able to SET ROLE to it. The createrole_self_grant
* GUC can be used to make this happen automatically. This has no
* security implications since the same user is able to make the same
* grant using an explicit GRANT statement; it's just convenient.
*/
if (createrole_self_grant_enabled)
AddRoleMems(currentUserId, stmt->role, roleid,
memberSpecs, memberIds,
currentUserId, &createrole_self_grant_options);
but I have not posted this fragment. - it requires adding createrole_self_grant_enabled
GUC and more related changes.
* grant. They can however grant the created role back to themselves with | ||
* different options, since they enjoy ADMIN OPTION on it. | ||
*/ | ||
if (!superuser()) |
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.
Why not for roles which are superuser?
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.
Superuser in any case has admin permission so no need to make this trick.
Co-authored-by: Konstantin Knizhnik <[email protected]>
Co-authored-by: Konstantin Knizhnik <[email protected]>
Co-authored-by: Konstantin Knizhnik <[email protected]>
Co-authored-by: Konstantin Knizhnik <[email protected]>
Co-authored-by: Konstantin Knizhnik <[email protected]>
Co-authored-by: Konstantin Knizhnik <[email protected]>
Co-authored-by: Konstantin Knizhnik <[email protected]>
Co-authored-by: Konstantin Knizhnik <[email protected]>
Co-authored-by: Konstantin Knizhnik <[email protected]>
See https://neondb.slack.com/archives/C04USJQNLD6/p1689973957908869