How to get space permissions of all spaces for specific user groups
Platform Notice: Data Center and Cloud By Request - This article was written for the Atlassian data center platform but may also be useful for Atlassian Cloud customers. If completing instructions in this article would help you, please contact Atlassian Support and mention it.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.
You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.
We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!
Summary
Database query to get details about space permissions of all the spaces in Confluence for a specific set of user groups.
Environment
Confluence Data Center
Solution
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Note
These database queries are tested on PostgreSQL Database
- Below are all possible space permissions which can be given for space, to a user/users or to a group/groups
permtype
---------------------
SETSPACEPERMISSIONS
EXPORTSPACE
VIEWSPACE
SETPAGEPERMISSIONS
REMOVEBLOG
REMOVEPAGE
EDITSPACE
CREATEATTACHMENT
REMOVEOWNCONTENT
COMMENT
REMOVECOMMENT
EDITBLOG
REMOVEMAIL
REMOVEATTACHMENT
- When you have to check space permissions of all the spaces in confluence for a specific set of user groups
You need to replace '<group1>', '<group2>' with the groups from your environment, in the below query:
Database query to check permissions for both groups for all spaces
PostgreSQLSELECT distinct sp.permtype FROM SPACEPERMISSIONS sp JOIN SPACES s ON sp.spaceid = s.spaceid LEFT JOIN user_mapping um ON sp.permusername = um.user_key WHERE sp.permgroupname IN ('<group1>', '<group2>');
- When you have to check space permissions of one space for two groups
You need to replace '<group1>', '<group2>' with the groups from your environment and the '<spacename>' as per your requirement, in the below query:
Database query to check space permissions of one space for two groups
PostgreSQLSELECT sp.permid, sp.permtype, s.spacekey, s.spacename, sp.permgroupname FROM SPACEPERMISSIONS sp JOIN SPACES s ON sp.spaceid = s.spaceid LEFT JOIN user_mapping um ON sp.permusername = um.user_key WHERE s.spacename = '<spacename>' and sp.permgroupname IN ('<group1>', '<group2>');
- When you have to check the space permissions of all the personal spaces for groups , this query will check permissions for personal spaces only.
You need to replace '<group1>', '<group2>' with the groups from your environment, in the below query:
Database query to check the permissions for ALL of the personal space for groups - "'<group1>', '<group2>'"
PostgreSQLSELECT * FROM SPACEPERMISSIONS AS SP ,SPACES AS S WHERE SP.SPACEID=S.SPACEID AND S.SPACETYPE='personal' AND SP.PERMGROUPNAME IS NOT NULL AND SP.PERMGROUPNAME IN ('<group1>', '<group2>');