Group permissions in Confluence

Rumceisz April 25, 2012

Hi All,

I would like to know which Confluence space does a group have access to? In Jira it can be check which project does a group access to. Is there a feature for Confluence too?

I need to know this because we manage some groups only for page restriction purpose so we would like to know which group gives space permission.

Thanks in advance!

Best regards,

Rumi

6 answers

1 accepted

1 vote
Answer accepted
Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2012

Hi Rumi,

Not sure if this is what you're looking for, but the following user macro will loop through all of the Spaces in an installation and list the groups that have permission to view each Space.

## Macro title: Space Group Permissions
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 27 Apr 2012
## Installed by: <your name>

## Macro to list all Spaces in an installation with the Groups that have permission to view each Space.
## @noparams

<h1>Space Group Permissions</h1>

<p>This installation contains the following Spaces and the listed groups have permission to view each Space.</p>

#foreach ($space in $spaceManager.getAllSpaces())
  <h2>$space.getName()</h2>
  <p>The following groups can view the $space.getName() Space.</p>
  <ul>
  #foreach ($permission in $space.getPermissions())
    #if ($permission.isGroupPermission() && $permission.getType() == "VIEWSPACE")
      <li>$permission.getGroup()</li>
    #end
  #end
  </ul>
#end

If you need to tweak it to see what other permissions a group has you can modifiy the following line:

#if ($permission.isGroupPermission() && $permission.getType() == "VIEWSPACE")

using one of the following permissions:

  • VIEWSPACE
  • COMMENT
  • EDITSPACE
  • SETSPACEPERMISSIONS
  • REMOVEPAGE
  • REMOVECOMMENT
  • REMOVEBLOG
  • CREATEATTACHMENT
  • REMOVEATTACHMENT
  • EDITBLOG
  • EXPORTPAGE
  • EXPORTSPACE
  • REMOVEMAIL
  • SETPAGEPERMISSIONS

Hope that helps?

Andrew.

Rumceisz April 26, 2012

Hi Andrew,

I created this macro to our Confluence, but where can we get the results? Is there a display where I can get the result? Or have to be added a page?

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2012

Hi Rumi,

If you've created a user macro you should be able to see the results by using {your macro name} on any standard page in Confluence, e.g. {spacegroups}

You may want to create a dedicated page for it as the output is going to be lengthy if you have a lot of Spaces and Groups, but you should be able to use the macro anywhere.

Does that help?

Andrew.

Rumceisz May 2, 2012

Hi Andrew,

many thanks for the macro, it works.

Another question: how should be changed the script to list it reverse? I mean not by list the spaces one by one, but the groups in ascending order and list which space(s) has the group permission?

Like this:

group1

has permission (at least viewonly) to the following spaces:

SpaceA

SpaceB

.....

group2

has permission (at least viewonly) to the following spaces:

SpaceC

SpaceA

etc.

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

Hi Rumi,

I'll have a look and get back to you - it might be a bit resource intensive as (off the top of my head) it would have to loop through every Space for every Group as I don't think there's anything on a Group object that tells you what Spaces it can access.

Should be do-able, but it might be slow to render on large installs.

Andrew.

Christian Czaia _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

Hey Andrew. How could I extend the macro to also list individual users?

Thx Christian

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

@Christian, have a look at a post (http://blog.networkedcollaboration.com/2012/04/28/confluence-space-administrators-remixed/) I wrote for something similar to what you're looking for. For the code in the post just change "SETSPACEPERMISSIONS" to "VIEWSPACE"

Andrew.

Christian Czaia _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

Nice, I was just looking at it at the moment. I just sort of googled you and followed the link to your blog :-) Greta work. Cheers Christian

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

Glad you like it :-)

Rumceisz May 3, 2012

Hi Andrew,

I checked your macro for member list of admin users (http://blog.networkedcollaboration.com/2012/04/28/confluence-space-administrators-remixed/).

Hence, I am a VB developer, I couldn't edit the code: I would like to extend this macro with the following: listing the groups with read only permission, and then in the next section with comment permission and at the end list with admin permission. I tired to insert an 'elseif' statement but it didn't work for me. It may be a very easy script but I'm not very familiar with this scripting.

Thanks in advance!


Rumi

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2012

Hi Rumi,

The easiest way with that macro is to just duplicate the following code block 3 times:

#foreach ($permission in $space.getPermissions())
  #if ($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
    #set ( $groupString = $permission.getGroup() )
    #set ( $groupObject = $userAccessor.getGroup($groupString) )
    #set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )

    <h3>$groupString</h3>
    <table class="confluenceTable">
      <tr>
        <th class="confluenceTh">Space Administrators</th>
      </tr>

      #foreach ($member in $memberList)
        <tr>
          <td class="confluenceTd">#usernameLink($member)</td>
        </tr>
      #end
    </table>
  #end
#end

Once with $permission.getType() == "VIEWSPACE" , once with $permission.getType() == "COMMENT" and once with $permission.getType() == "SETSPACEPERMISSIONS"

Not the prettiest way of doing it, but it should do what you want.

Hope that helps?

Andrew.

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 5, 2012

Hi Rumi,

Here's another version of the macro which lists all the groups with the permissions they have on each space:

## Macro title: Group Permissions
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 06/05/2012
## Installed by: <your name>

## Macro loops through every group and every space listings permissions on that space grouped by group
## @noparams

<h1>Groups</h1>

## get all the groups
#set ( $allGroups = $userAccessor.getGroupsAsList() )

## get all the spaces
#set ( $allSpaces = $spaceManager.getAllSpaces() )

#foreach ($group in $allGroups)
  <h2>$group</h2>
  #foreach ($space in $allSpaces)
    <h3>$space.getName()</h3>
    #foreach ($permission in $space.getPermissions())
      #if ($permission.isGroupPermission())
        #if ($permission.getGroup() == $group)
          $permission.getType()<br />
        #end
      #end
    #end
  #end
#end

The formatting is not very pretty, but it should give you the information you wanted grouped by group.

Andrew.

Rumceisz May 6, 2012

Hi Andrew,

the last one works! It's fantastic. Thanks you very much!!!

For each groups all the spaces and personal spaces are listed, not just those the group has permission. How can change the script that only those spaces/personal spaces will be listed that the group have permissions to. Hence, we have about 70 spaces and 20-25 personal spaces.

Something:

#if ($permission.isGroupPermission()) <> ""
but it didn't work for me.

Thanks you again!

Rumi

Rumceisz May 7, 2012

Hi Andrew,

is there any way that uses 'if' statement in the code above?

I mean, when I inserted the code 3 times, it will display many groups 2 or 3 times.

I feel sorry for exploiting you, but I am not very good in this script.

Many thanks!

Rumi

Hi Rumi,

The easiest way with that macro is to just duplicate the following code block 3 times:

#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
#set ( $groupString = $permission.getGroup() )
#set ( $groupObject = $userAccessor.getGroup($groupString) )
#set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
<h3>$groupString</h3>
<table class="confluenceTable">
<tr>
<th class="confluenceTh">Space Administrators</th>
</tr>
#foreach ($member in $memberList)
<tr>
<td class="confluenceTd">#usernameLink($member)</td>
</tr>
#end
</table>
#end
#end

Once with $permission.getType() == "VIEWSPACE" , once with $permission.getType() == "COMMENT" and once with $permission.getType() == "SETSPACEPERMISSIONS"

Not the prettiest way of doing it, but it should do what you want.

Hope that helps?

Andrew.

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2012

Hi Rumi,

I've been looking at a better way to present the permissions info, but I haven't got it figured out yet. Will post back here if and when I do.

Andrew.

Rumceisz May 13, 2012

Hi Andrew,

have you found something to solve this DEvnull. I also triing a code.

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 13, 2012

Hi Rumi,

Sorry, not had chance to look at this properly yet.

Andrew.

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 15, 2012

Hi Rumi,

Has the requirement changed? Looking at https://answers.atlassian.com/questions/54728/display-all-the-groups-users-of-each-space that's a different requirement to what's being asked here. This thread asks for permissions grouped by group and the other thread asks for permissions grouped by space.

Andrew.

Rumceisz May 15, 2012

Hi Andrew,

yes the users clarified at last. Sorry, for confusing you in the above comments.

What we would like to achieve on a page is the following:we admins need to see all the spaces in our Confluence instance. Under each space all the related groups would listed with the permissions the group grants in that particular space. And under the group all the group members would be listed in a table.

This is how it would look like:

SpaceA

group1

permissions: VIEW, EXPORT, RESTRICT PAGE, etc...

group members:

John Doe

Gary Smith

.....

group113

permissions: VIEW

group members:

Kate Jacobs

...

SpaceB

group1

permissions: VIEW, EXPORT, RESTRICT PAGE, ADMIN, etc...

group members:

John Doe

Gary Smith

.....

Of course the formatting doesn't matter.

You posted macros for all the features above, but apart. I tried to concatenate these macro scripts but I am layman in this scripting language.

Many thanks for your helps so far!

Rumi

Rumceisz June 6, 2012

Hi Andrew,

can you please have a look:

https://answers.atlassian.com/questions/59811/space-groups-and-permissions

Thank you!

Rumi

1 vote
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 25, 2012

Have a look at the Confluence data model and create your own SQL statement. Blog about your results (or add them here as a comment) :)

Related: Here's a bunch of SQL scripts that Betsy Walker wrote up.

0 votes
Thomas Schlegel
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 25, 2012

Hi Rumi,

great request :-)

I'm wondering why noone else has requested this before. Maybe you should open a feature request and post the link here, so everyone can vote for it.

Best regards

Thomas

0 votes
Rumceisz April 25, 2012

If there is a script, ot would be also appropriate.

0 votes
Rumceisz April 25, 2012

Hi Christian,

well we start hoping for a feature:)

I am convinced that this a wide range of claim here.

Regards,

Rumi

0 votes
Christian Czaia _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 25, 2012

I'd be interested in this, too. Maybe some SQL script we could use? Thanks in advance, Cheers Christian

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events