Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I assign a new group permission to all existing spaces in Confluence ?

Hi,

We have a few hundred spaces, and need permission for a new group for all spaces. Is it possible to do this maybe with an sql-script ? 

Changing default permission will only take effect to new spaces, and I really don't want change space permission by "hand" .

I would be glad to get a simple solution.

Gabriele

2 answers

You can do this using the Confluence CLI (paid plugin), or you can use this method (I find it works best with the Chrome browser, but Firefox and IE should work too).

  1. Confluence Remote API access should be activated (usually is by default).
  2. You need to be logged in as a Confluence Administrator (a member of "confluence-administrators" group).
  3. Open up the javascript console (usually by pressing F12 and finding "Console" or Ctrl+Shift+J)
  4. Copy/paste the following code, but before copying, change "group_name" to the name of the group you wish to add permissions for, and for each permission you want to add, remove the "//" at the beginning of the line (they correspond from left to right each of the permissions in the Manage Permissions screen): 

    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");
                      //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");
                      requestArray.push(permissionsArray);
                      requestArray.push("group_name");
                      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);
                                  }
                      });
                    }
                  });
                }
    });
  5. Press enter, and you should hopefully see true a bunch of times (or with a high number next to it).  You should be done!

Hi,

was trying your script, but i get the following error in the console:

Uncaught SyntaxError: Invalid or unexpected token 

appreciate your help.

thx, cheers, Mike

What can I change to remove the permission from all spaces instead?

Hi @Stephen Deutsch 

This is awesome! Thanks so much. One question: is there a way I can use this to apply it to an array of spaces, rather than just all of them?

Best wishes

Adam

Like WW likes this

This worked great! Awesome!

Like Gabriele Loibichler likes this

This worked for me except that it did not set the "Delete Own" permission.  I'm guessing this either changed name or is a new permission.

Ive been working on this and the below command does Delete Own Permission:

permissionsArray.push("REMOVEOWNCONTENT");

Thanks!

 

I will give that a try next time I need it.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Miss the Confluence demos at Team 21? Watch them here!

Phew, Atlassian Team 2021 blew by. With dozens of demos and a handful of keynotes, you may have missed some of the awesome Confluence Cloud sessions. Don't' worry, you can watch them all here or on Y...

383 views 2 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you