当前位置:网站首页>Database postragesq role membership
Database postragesq role membership
2022-07-05 01:13:00 【wx5d0241bb88268】
21.3. Role membership
It's often convenient to group users together to manage permissions : like that , Permissions can be granted to or reclaimed from an entire group . stay PostgreSQL By creating a role that represents a group , And then the membership in that group role is granted to a separate user role .
To create a group role , First create the character :
CREATE ROLE name;
Roles that are usually used as a group do not need to have LOGIN attribute , But if you want to, you can also set it up . Once the group role exists , You can use GRANT and REVOKE Command to add and remove members :
GRANT group_role TO role1, ... ;
REVOKE group_role FROM role1, ... ;
- 1.
- 2.
You can also grant membership to other group roles ( Because there's no difference between a group role and a non group role ). The database will not let you set up ring Membership . in addition , Membership in a role is not allowed to be granted to PUBLIC.
Members of a group role can use role permissions in two ways . First of all , Each member of can be explicitly a group SET ROLE Coming “ Become ” Group roles . In this state , The database session can access the permissions of the group role instead of the original login role , And any database object created is considered to belong to the group role rather than the login role . second , Yes INHERIT Attribute's member roles automatically have the permissions of the role to which they belong , Include permissions inherited from any group role . As an example , Suppose we already have :
CREATE ROLE joe LOGIN INHERIT;
CREATE ROLE admin NOINHERIT;
CREATE ROLE wheel NOINHERIT;
GRANT admin TO joe;
GRANT wheel TO admin;
- 1.
- 2.
- 3.
- 4.
- 5.
As a character joe After connection , A database session will have immediate ownership granted directly to joe Authority , Plus any grant to admin Authority , because joe“ Inherited ” admin Authority . However , Granted to wheel Permission for is not available , Because even if joe yes wheel An indirect member of , But the membership is through the belt NOINHERIT Attribute admin Got . stay :
SET ROLE admin;
after , The session will only have the grant to admin Authority , But not to joe Authority . In execution :
SET ROLE wheel;
after , The session will only have the grant to wheel Authority , But not to joe or admin Authority . The initial permission state can be restored using one of the following commands :
SET ROLE joe;
SET ROLE NONE;
RESET ROLE;
- 1.
- 2.
- 3.
SET ROLE The command always allows you to select the direct or indirect group role of the original login role . therefore , In the example above , Is becoming wheel You don't have to be admin.
stay SQL In the standard , The difference between users and roles is clear , And users don't automatically inherit permissions, but roles do . This kind of behavior PostgreSQL Can also be achieved in : To be used for SQL The role of the character gives INHERIT attribute , To be used as SQL The role of the user is given NOINHERIT attribute .
however , For backward compatibility 8.1 Previous releases ( Where users always have the rights of their group ),PostgreSQL Default to all characters INHERIT attribute .
Character attributes LOGIN、SUPERUSER、CREATEDB and CREATEROLE It can be thought of as a special privilege , But they
It is never inherited like normal permissions on database objects . To use these properties , You have to be practical SET ROLE To a specific character with one of these attributes . Continue with the above example , We can choose to award CREATEDB and CREATEROLE to admin role . And then one with joe The session to which the role is connected will not immediately have these permissions , Only in execution SET ROLE admin Only after that will we have it .
To destroy a group character , Use DROP ROLE:
DROP ROLE name;
The membership of any role in the group is automatically revoked ( But the member role is not affected ).
边栏推荐
- Liangzai's first program life and annual summary in 2022
- [Yocto RM]10 - Images
- Check if this is null - checking if this is null
- Global and Chinese markets for industrial X-ray testing equipment 2022-2028: Research Report on technology, participants, trends, market size and share
- Database postragesql lock management
- A simple SSO unified login design
- 如果消费互联网比喻成「湖泊」的话,产业互联网则是广阔的「海洋」
- Expansion operator: the family is so separated
- Redis master-slave replication cluster and recovery ideas for abnormal data loss # yyds dry goods inventory #
- JS implementation determines whether the point is within the polygon range
猜你喜欢
每日刷题记录 (十三)
大专学历,33岁宝妈又怎样?我照样销售转测试,月入13k+
Implementation steps of master detail detail layout mode of SAP ui5 application
Basic operation of database and table ----- the concept of index
FEG founder rox:smartdefi will be the benchmark of the entire decentralized financial market
[wave modeling 3] three dimensional random real wave modeling and wave generator modeling matlab simulation
Roads and routes -- dfs+topsort+dijkstra+ mapping
What happened to those who focused on automated testing?
There is a new Post-00 exam king in the testing department. I really can't do it in my old age. I have
【海浪建模3】三维随机真实海浪建模以及海浪发电机建模matlab仿真
随机推荐
微信小程序;胡言乱语生成器
Poap: the adoption entrance of NFT?
[development of large e-commerce projects] performance pressure test - Performance Monitoring - heap memory and garbage collection -39
Detailed explanation of multi-mode input event distribution mechanism
Hand drawn video website
【FPGA教程案例9】基于vivado核的时钟管理器设计与实现
整理混乱的头文件,我用include what you use
Analysis and comparison of leetcode weekly race + acwing weekly race (t4/t3)
Global and Chinese market of portable CNC cutting machines 2022-2028: Research Report on technology, participants, trends, market size and share
华为百万聘请数据治理专家!背后的千亿市场值得关注
实战模拟│JWT 登录认证
La jeunesse sans rancune de Xi Murong
[Yocto RM]11 - Features
微信小程序:独立后台带分销功能月老办事处交友盲盒
Basic operation of database and table ----- phased test II
Jcenter () cannot find Alibaba cloud proxy address
Take you ten days to easily complete the go micro service series (IX. link tracking)
小程序直播 + 电商,想做新零售电商就用它吧!
Inventory of more than 17 typical security incidents in January 2022
Postman automatically fills headers