当前位置:网站首页>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 ).
边栏推荐
- Jcenter () cannot find Alibaba cloud proxy address
- 無心劍英譯席慕容《無怨的青春》
- Delaying wages to force people to leave, and the layoffs of small Internet companies are a little too much!
- [development of large e-commerce projects] performance pressure test - Performance Monitoring - heap memory and garbage collection -39
- College degree, what about 33 year old Baoma? I still sell and test, and my monthly income is 13K+
- Digital DP template
- La jeunesse sans rancune de Xi Murong
- 107. SAP UI5 OverflowToolbar 容器控件以及 resize 事件处理的一些细节介绍
- [wave modeling 1] theoretical analysis and MATLAB simulation of wave modeling
- [development of large e-commerce projects] performance pressure test - Optimization - impact of middleware on performance -40
猜你喜欢
Visual explanation of Newton iteration method
What if the programmer's SQL data script coding ability is weak and Bi can't do it?
Daily question brushing record (13)
There is a new Post-00 exam king in the testing department. I really can't do it in my old age. I have
微信小程序;胡言乱语生成器
dotnet-exec 0.6.0 released
Analysis and comparison of leetcode weekly race + acwing weekly race (t4/t3)
Poap: the adoption entrance of NFT?
[wave modeling 3] three dimensional random real wave modeling and wave generator modeling matlab simulation
JS implementation determines whether the point is within the polygon range
随机推荐
创新引领方向 华为智慧生活全场景新品齐发
There is a new Post-00 exam king in the testing department. I really can't do it in my old age. I have
【大型电商项目开发】性能压测-优化-中间件对性能的影响-40
SAP UI5 应用的主-从-从(Master-Detail-Detail)布局模式的实现步骤
微信小程序;胡言乱语生成器
Basic concept and usage of redis
全栈开发提效神器——ApiFox(Postman + Swagger + Mock + JMeter)
Global and Chinese market of network connected IC card smart water meters 2022-2028: Research Report on technology, participants, trends, market size and share
小程序直播 + 电商,想做新零售电商就用它吧!
RB technology stack
Roads and routes -- dfs+topsort+dijkstra+ mapping
Global and Chinese market of portable CNC cutting machines 2022-2028: Research Report on technology, participants, trends, market size and share
The server time zone value ‘� й ��� ʱ 'is unrecognized or representatives more than one time zone【
6. Scala operator
The most complete regular practical guide of the whole network. You're welcome to take it away
What if the programmer's SQL data script coding ability is weak and Bi can't do it?
“薪资倒挂”、“毕业生平替” 这些现象说明测试行业已经...
Digital DP template
SAP UI5 应用开发教程之一百零七 - SAP UI5 OverflowToolbar 容器控件介绍的试读版
[pure tone hearing test] pure tone hearing test system based on MATLAB