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

Only allow to modify roles on which the session user as admin_option #47

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rdunklau
Copy link
Contributor

Only checking that the user was not a superuser was fine, but with PG16 more granular philosophy of restricting operations on roles on which we have ADMIN membership, we should do the same here.

@rdunklau rdunklau requested a review from a team as a code owner January 18, 2024 14:17
@rdunklau rdunklau marked this pull request as draft January 30, 2024 11:23
@rdunklau rdunklau force-pushed the rdunklau/prevent_random_role_changes branch from 3da9d2b to d2087e3 Compare May 15, 2024 11:51
@rdunklau rdunklau force-pushed the rdunklau/prevent_random_role_changes branch from d2087e3 to a2bb2f3 Compare May 15, 2024 15:03
END IF;
WITH RECURSIVE tree AS (
-- Start with the possibly admin_role
SELECT member AS base_role, roleid, admin_option, member FROM pg_auth_members
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the WHERE base_role = session_user::regrole::oid be applied in the initial set? At least if I read this right, you start with all rows in pg_auth_members and then add even more rows to it by adding the rows again which have members, only to drop all rows which are not having the above condition.

@rdunklau rdunklau force-pushed the rdunklau/prevent_random_role_changes branch from 1f675a5 to 01e145b Compare May 24, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants