-
Notifications
You must be signed in to change notification settings - Fork 2
Limit database connection only to users known to that database #282
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
base: dev
Are you sure you want to change the base?
Conversation
Permit db connection when a login role is created; revoke db connection when a role name no longer has any ClassDB role.
DB connection is now managed separately for each role with login. Fixes #278
|
All unit and privilege tests pass for me. I also tested this change with role in multiple ClassDB instances and each role was only able to connect to the databases it was added to (as expected). The only small issue which we already discussed in our meeting is that there is a misspelling in a comment on line 314 of Thank you for implementing this temporary solution @smurthys |
|
Thanks for the review and for testing @KevinKelly25. I see one issue in |
|
One possible approach is that we can run the following if the FOR User IN
SELECT RoleName FROM ClassDB.RoleBase
LOOP
EXECUTE FORMAT('GRANT CONNECT ON DATABASE %I TO %s', current_database(), User);
END LOOP;The problem with this approach is that this will also be run if user already can connect to the database. I do not believe this causes an error (worth checking though) so it is more of an efficiency problem. |
|
Thanks for the tip @KevinKelly25. I played around with a similar solution. The query needs to be over pg_roles table if executed in |
|
I agree it logically should be in |
|
Indeed. |
The commits in this PR remove automatic DB connection to ClassDB group roles (at DB initialization) and instead manage that permission separately for each login role: grants permission in function
createRole; revokes permission in functionrevokeClassDBRoleif the role has no more ClassDB roles.These commits fix #278.
This fix can be removed when Issue #277 is fixed, assuming that issue is addressed by creating database-specific names for ClassDB group roles as proposed in a comment at that issue.
The changes are tested manually. Privilege tests need to be updated.