Details
-
Type:
Suggestion
-
Status: Gathering Interest (View Workflow)
-
Resolution: Unresolved
-
Fix Version/s: None
-
Component/s: User - Global / Space Permissions
-
Labels:
-
UIS:410
-
Support reference count:28
-
Feedback Policy:
Description
NOTE: This suggestion is for Confluence Server. Using Confluence Cloud? See the corresponding suggestion.
We have dozens of spaces and need ability to programmatically update space permissions. Otherwise it's a really wasteful manual effort.
Workaround
While this is not possible through the REST API, Confluence users and administrators can still use the legacy RPC API to administrate Space Permissions.
The following document describes the JSON-RPC API: Confluence JSON-RPC APIs.
The following document highlights all the methods available in the RPC API to manage Space Permissions: Remote Confluence methods – Permissions.
The following link will send you to a mapping about each space permission string and their related permission: Remote Confluence methods – Space Permissions.
Below are a few examples of how to use this API to perform Space Permissions operations.
This is using Shell Script just as an example, since it can be ported to your preferred coding language.
In these examples, the jq library is used to filter and format the raw output.
Get all permissions associated to a Space
####### # Attributes to set ####### ADMIN_USRNAME=<username to perform basic authentication> ADMIN_USRPWD=<password to perform basic authentication> CONFLUENCE_BASE_URL=<Confluence Base URL> SPACE_KEY=<Target Space Key> ####### Run the API method API_METHOD=getSpacePermissionSets curl --user $ADMIN_USRNAME:$ADMIN_USRPWD -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{ "jsonrpc" : "2.0", "method" : "'${API_METHOD}'", "params" : ["'${SPACE_KEY}'"], "id": 7 }' ${CONFLUENCE_BASE_URL}/rpc/json-rpc/confluenceservice-v2?os_authType=basic 2>/dev/null | jq -r '.result[]'
Running example and output excerpt:
Get users and groups assigned as Space Administrators to a Space
####### # Attributes to set ####### ADMIN_USRNAME=<username to perform basic authentication> ADMIN_USRPWD=<password to perform basic authentication> CONFLUENCE_BASE_URL=<Confluence Base URL> SPACE_KEY=<Target Space Key> PERMISSION_TYPE=<permission type string> ####### Run the API method API_METHOD=getSpacePermissionSet curl --user $ADMIN_USRNAME:$ADMIN_USRPWD -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{ "jsonrpc" : "2.0", "method" : "'${API_METHOD}'", "params" : ["'${SPACE_KEY}'", "'${PERMISSION_TYPE}'"], "id": 7 }' ${CONFLUENCE_BASE_URL}/rpc/json-rpc/confluenceservice-v2?os_authType=basic 2>/dev/null | jq -r '.result[]'
Running example and output excerpt:
Set Add Page permission to a specific group in a Space
####### # Attributes to set ####### ADMIN_USRNAME=<username to perform basic authentication> ADMIN_USRPWD=<password to perform basic authentication> CONFLUENCE_BASE_URL=<Confluence Base URL> SPACE_KEY=<Target Space Key> GROUP_NAME=<Target Group Name> PERMISSION_TYPE=EDITSPACE ####### Run the API method API_METHOD=addPermissionToSpace curl --user $ADMIN_USRNAME:$ADMIN_USRPWD -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{ "jsonrpc" : "2.0", "method" : "'${API_METHOD}'", "params" : ["'${PERMISSION_TYPE}'", "'${GROUP_NAME}'", "'${SPACE_KEY}'"], "id": 7 }' ${CONFLUENCE_BASE_URL}/rpc/json-rpc/confluenceservice-v2?os_authType=basic 2>/dev/null | jq -r '.'
Running example and output excerpt:
Set Delete Attachments to a specific user in a Space
####### # Attributes to set ####### ADMIN_USRNAME=<username to perform basic authentication> ADMIN_USRPWD=<password to perform basic authentication> CONFLUENCE_BASE_URL=<Confluence Base URL> SPACE_KEY=<Target Space Key> USER_NAME=<Target Username> PERMISSION_TYPE=<permission type string> ####### Run the API method API_METHOD=addPermissionToSpace curl --user $ADMIN_USRNAME:$ADMIN_USRPWD -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{ "jsonrpc" : "2.0", "method" : "'${API_METHOD}'", "params" : ["'${PERMISSION_TYPE}'", "'${USER_NAME}'", "'${SPACE_KEY}'"], "id": 7 }' ${CONFLUENCE_BASE_URL}/rpc/json-rpc/confluenceservice-v2?os_authType=basic 2>/dev/null | jq -r '.'
Attachments
Issue Links
- relates to
-
CONFCLOUD-44329 Ability to set space permissions via REST API
- Closed
- mentioned in
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...