Groovy script to check if a user has access to a given space

Patrick Vanhoof
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.
December 9, 2020

Hi,

Well, the question says it all I think :)

I would like to check in a script if a given user has access to a given space. That is, I am iterating through the users of the confluence-uers group, and for each user I want to check if the user has access to e.g. space with key "ABCD".

The iteration works, it's only the space permission check that I do not know how to do that. 

Any help appreciated,

Patrick

1 answer

1 vote
Patrick Vanhoof
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.
December 15, 2020

Think I found it:

import com.atlassian.confluence.security.PermissionHelper

def permissionHelper = ComponentLocator.getComponent(PermissionHelper)

if (permissionHelper.canView(user, space) {
}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events