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

Add README on adding new read-only accounts to PostgreSQL #79

Closed
frol opened this issue Mar 19, 2021 · 5 comments · Fixed by #82
Closed

Add README on adding new read-only accounts to PostgreSQL #79

frol opened this issue Mar 19, 2021 · 5 comments · Fixed by #82
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@frol
Copy link
Contributor

frol commented Mar 19, 2021

No description provided.

@frol
Copy link
Contributor Author

frol commented Mar 25, 2021

Unfortunately, the instructions we used (and provided in the PR) are not sufficiently strict, and allow creating new tables, inserting values there, creating new materialized views etc.

Thanks @telezhnaya for reporting it. @telezhnaya May I ask you to find the right set of incantations to achieve the true read-only mode? 😄

I have seen a few places where it is explained that even a new user with no permission granted has access to the public schema sufficient to create new tables (and thus owning those), and they suggest revoking permissions to public, but I was not very successful. Some references:

@frol frol reopened this Mar 25, 2021
@frol frol assigned telezhnaya and unassigned khorolets Mar 25, 2021
telezhnaya pushed a commit that referenced this issue Mar 29, 2021
@telezhnaya
Copy link
Contributor

it is explained that even a new user with no permission granted has access to the public schema sufficient to create new tables

That's true. That's why it's better to use non-default schema for the project.
public is not just regular schema, it has some exceptions as the default option.

Ideally, we need to invoke this command from admin account: REVOKE CREATE ON SCHEMA public FROM PUBLIC;
It's enough to invoke this command once, and all users except admin will have read-only access to the tables. With that, we will not need to edit our instruction.

My commit was tested it only in the sandbox. I need another account (with more permissions) to test it in real DB.

telezhnaya added a commit that referenced this issue Apr 2, 2021
telezhnaya added a commit that referenced this issue Apr 2, 2021
@telezhnaya
Copy link
Contributor

telezhnaya commented Apr 2, 2021

To sum up:
We have new migration, we also need to invoke

REVOKE CREATE ON SCHEMA PUBLIC FROM PUBLIC;
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA PUBLIC FROM PUBLIC;

In my opinion, it should not be a part of migration

@telezhnaya
Copy link
Contributor

@frol I deployed these changes to mainnet and testnet

@telezhnaya
Copy link
Contributor

#89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants