graphile / graphile/graphile.github.io
Clarify the importance of NOINHERIT to properly create a role on the DOCS
- Ngôn ngữ chính
- SCSS
- Star
- 27
- Fork
- 126
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
When a ROLE is created in PG, it may inherit privileges from other roles. It specially inherits all privileges from the PUBLIC role.
[From the DOCs](https://www.postgresql.org/docs/9.5/sql-grant.html):
"Any particular role will have the sum of privileges granted directly to it, privileges granted to any role it is presently a member of, and privileges granted to PUBLIC.".
If your application is implementing a whitelist logic (most of the cases), this may represent a leak of authorization. So all roles must be created using the NOINHERIT clause, but there is another gotcha: creating a role and them altering it to NOINHERIT is a safer option than creating a role with NOINHERIT.
```
-- OK if there is no graphile_visitor already in your system
CREATE ROLE graphile_visitor NOINHERIT;
-- A better option, specially during development if you use dropdb to "reset" your application
CREATE ROLE graphile_visitor;
ALTER ROLE graphile_visitor NOINHERIT;
```
When a ROLE is created, it's not stored into the database itself, but inside a private catalog called pg_user. If graphile_visitor by accident was crate without the NOINHERIT, dropping the database won't erase it, so adding the NOINHERIT to its creation clause afterward will have no effect at all.
```
-- this is a mistake
CREATE ROLE graphile_visitor;
-- this isn't a bug fix
CREATE ROLE graphile_visitor NOINHERIT;
```
This happens because, when it runs the second query, PG will identify that a role with the same name already exists so it will skip the CREATE ROLE. Keeping creation and alteration separated will ensure the intended behavior.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu bằng cách xem lại tài liệu PostgreSQL GRANT được liên kết trong issue và tìm phần hướng dẫn tương ứng về việc tạo role trong repository này. Làm rõ hành vi của NOINHERIT, tính duy trì của role và ví dụ ALTER ROLE riêng biệt; được coi là hoàn tất khi tài liệu giải thích chính xác rủi ro ủy quyền và không ngụ ý rằng một CREATE ROLE được thực hiện sau đó sẽ thay đổi một role hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- postgresql
- Lĩnh vực
- documentation, security
- Loại issue
- Tài liệu
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100