Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

ScriptRunner for Confluence - Generate List of Group Permissions for ALL Spaces

Russell Kent
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 8, 2024

I'm trying to find a way to generate a list that will show which spaces contain permissions for a specific user group. I DO NOT want this script to delete or modify any permissions, I just want the list. I looked on the forums and found a few related articles, but nothing seems to be working for me.

This script from the Adaptavist library seems like a good starting point, but I'm a newbie with scripts so I don't know what needs to be modified to generate a list rather than remove space permissions. Also, I do not know what fields should be updated in the template to run the script (the group I'm looking into is called: WikiAnnouncers) 

Adaptavist Script Example: https://library.adaptavist.com/entity/remove-space-permissions-for-a-specified-group-on-all-spaces 

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 8, 2024

Hi @Russell Kent 

Welcome to the Community.

 

Here is a modified script based on the one in the library that will print out all the permissions for the selected group:

import groovy.xml.MarkupBuilder
import com.atlassian.confluence.internal.security.SpacePermissionManagerInternal
import com.atlassian.confluence.security.SpacePermissionManager
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.sal.api.component.ComponentLocator
import com.onresolve.scriptrunner.parameters.annotation.GroupPicker

@GroupPicker(label = 'Group', description = 'Select the group to inspect')
Group selectedGroup
assert selectedGroup

def spacePermissionManager = ComponentLocator.getComponent(SpacePermissionManager) as SpacePermissionManagerInternal
def groupPermissions = spacePermissionManager.getAllPermissionsForGroup(selectedGroup.name)

def writer = new StringWriter()
def builder = new MarkupBuilder(writer)
builder.table(class: 'aui') {
thead {
tr {
th 'Space'
th 'Space Name'
th 'Space Type'
th 'Permission'
}
}
tbody {
groupPermissions.each { permission ->
if (!permission.space) return //don't print out non space permissions
tr {
td permission.space.key
td permission.space.name
td permission?.space?.spaceType
td permission.type
}
}
}
}

writer.toString()

I'm using the groovy markup builder to create a simple HTML table to output the data in a user-friendly way

TAGS
AUG Leaders

Atlassian Community Events