Add group permission to every Space

Florian Huber August 16, 2019

Hi!

 

I want to add a global read only group to every existing space.

I already set it in the default for new spaces, but how can I update all existing spaces?

1 answer

1 vote
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 16, 2019

Try this,

  • Login in to confluence using admin permission
  • move to and admin page
  • Open JS console in browser (CMD + SHIFT + I on MacOS)
  • Paste following JS code and press Enter.
jQuery.ajax({dataType: 'json',
            contentType: 'application/json',
            type: 'POST',
            url: contextPath + '/rpc/json-rpc/confluenceservice-v2/getSpaces',
            success: function( data ) {
              jQuery(data).each(function() {
                if (this.type === "global") {
                  var requestArray = [];
                  var permissionsArray = [];
                  permissionsArray.push("VIEWSPACE");
                 
                  requestArray.push(permissionsArray);
                  requestArray.push("<your_new_group>");
                  requestArray.push(this.key);
                  jQuery.ajax({dataType: 'json',
                              contentType: 'application/json',
                              type: 'POST',
                              url: contextPath + '/rpc/json-rpc/confluenceservice-v2/addPermissionsToSpace',
                              data: JSON.stringify(requestArray),
                              success: function( data ) {
                                console.log(data);
                              }
                  });
                }
              });
            }
});

 

You have to replace <your_new_group> with name of group.

You can add more permission to above 'permissionsArray' like this

permissionsArray.push("EDITSPACE");
permissionsArray.push("EXPORTPAGE");
permissionsArray.push("SETPAGEPERMISSIONS");
permissionsArray.push("REMOVEPAGE");
permissionsArray.push("EDITBLOG");
permissionsArray.push("REMOVEBLOG");
permissionsArray.push("COMMENT");
permissionsArray.push("REMOVECOMMENT");
permissionsArray.push("CREATEATTACHMENT");
permissionsArray.push("REMOVEATTACHMENT");
permissionsArray.push("REMOVEMAIL");
permissionsArray.push("EXPORTSPACE");
permissionsArray.push("SETSPACEPERMISSIONS");

 

You can try this on staging before running on production.

Florian Huber August 16, 2019

Hi!

 

Thank you  -it worked!

But @kuromiya - are you serious????

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events