Fixed documentation about PostgreSQL read-only user's default privileges - #521
Closed
LouisKottmann wants to merge 1 commit into
Closed
Fixed documentation about PostgreSQL read-only user's default privileges#521LouisKottmann wants to merge 1 commit into
LouisKottmann wants to merge 1 commit into
Conversation
…ges, that only applied to tables created by the postgres user that altered the default privileges (often the superadmin)
Owner
|
Hi @LouisKottmann, thanks for the suggestion. Improved the example in the commit above. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After many years of scratching my head about why new tables remained un-selectable from a PostgreSQL read-only user that had been given the likes of :
I finally figured it out (with help from our LLM friends).
It was in the docs all this time : turns out, if you call
ALTER DEFAULT PRIVILEGES ...without specifyingFOR ROLE, the automatic privilege (theGRANT/REVOKEpart in the right side of the command) is only applied when triggered (a table being created in our case) by the user who altered the default privileges.In other words, if you run
ALTER DEFAULT PRIVILEGES ...with the postgres user (common for bare-metal installs when managing users creations / rights), only tables created by the postgres user will trigger theGRANT SELECT ON TABLES TO blazer.And since people (at least me I guess) tend to run migrations as the app user (or even a dedicated user with elevated DDL rights when using a bouncer for example), the tables created over time are not granted as selectable to the blazer user.
The fix is in the PR, it's only a small documentation fix.
Here is a minimal reproduction in SQL :
> psql