Hey all,
I wanted to jump in here, I hope you're all enjoying some of the enhancements we've made for making it a bit easier to manage guests at scale. While we continue to make progress in this area, I wanted to share a potential short term solution for those of you that are leveraging our Confluence REST APIs.
What I've heard, is that there is a need to assign all guests, within a group, access to the same space. While default space access is a really good start, there may be some edge cases around it (maybe multiple groups needing different sets of space access).
The existing APIs that I wanted to highlight that could be leveraged to build a custom solution around space assignment, would be the following:
Leveraging those APIs we should be able to identify all guest users in a given group, and grant the required space permissions to "assign" space access for a guest (guests by default always be granted read:space, create:page, create:comment, and create:attachment on a given space).
Below is an example of a script that will use the APIs listed above to take a group name, lookup all of the guest users within that group, and assign the correct space permissions if possible (the space permission endpoint will return an error if the guest user already has a space assigned).
#!/bin/bash
groupName="[insert-group-name-here]" # The name of the guest group you want to assign spaces for
spaceKey="[insert-space-key-here]" # The space key of the space you want to assign to your guests
hostname=[insert-confluence-domain-here] # The domain for your Confluence site
result=$(http GET "$hostname/wiki/rest/api/group")
groupId=$(echo $result | jq -r '.results[] | select(.name=="'$groupName'") | .id')
result=$(http GET "$hostname/wiki/rest/api/group/$groupId/membersByGroupId?expand=isExternalCollaborator")
guestIds=$(echo $result | jq '.results[] | select(.isExternalCollaborator==true) | .accountId')
guestIds=($guestIds)
echo "Start assigning space permissions on $spaceKey for ${#guestIds[@]} guests..."
for guestId in "${guestIds[@]}"; do
(
if http --check-status --ignore-stdin POST "$hostname/wiki/rest/api/space/$spaceKey/permission" --raw '{ "subject": { "type": "user", "identifier": '"$guestId"' }, "operation": { "key": "read", "target": "space"}}' &>output.txt:; then
echo "✅ successfully assigned read:space on $spaceKey for $guestId"
if http --check-status --ignore-stdin POST "$hostname/wiki/rest/api/space/$spaceKey/permission" --raw '{ "subject": { "type": "user", "identifier": '"$guestId"' }, "operation": { "key": "create", "target": "page"}}' &>output.txt:; then
echo "✅ successfully assigned create:page on $spaceKey for $guestId"
else
echo "❌ failed to assign create:page on $spaceKey for $guestId"
fi
if http --check-status --ignore-stdin --meta POST "$hostname/wiki/rest/api/space/$spaceKey/permission" --raw '{ "subject": { "type": "user", "identifier": '"$guestId"' }, "operation": { "key": "create", "target": "comment"}}' &>output.txt:; then
echo "✅ successfully assigned create:comment on $spaceKey for $guestId"
else
echo "❌ failed to assign create:comment on $spaceKey for $guestId"
fi
if http --check-status --ignore-stdin --meta POST "$hostname/wiki/rest/api/space/$spaceKey/permission" --raw '{ "subject": { "type": "user", "identifier": '"$guestId"' }, "operation": { "key": "create", "target": "attachment"}}' &>output.txt:; then
echo "✅ successfully assigned create:attachment on $spaceKey for $guestId"
else
echo "❌ failed to assign create:attachment on $spaceKey for $guestId"
fi
else
echo "❌ failed to assign read:space on $spaceKey for $guestId"
fi
)
done
echo "Finished assigning space permissions on $spaceKey for ${#guestIds[@]} guests..."
Hopefully this information is helpful, if there are any questions, please reach out!
mwang@atlassian.com 9574dabfb3a9
Based on your "Latest Update" which describes Default Space Assignment, is there some way to define default permissions for this default guest assigment group?
The only ways I've found to define specific space permissions to users or groups is under /Space Permissions/, and none of the options enable defining a 'default permission set' for guests added via this 'default guest assignment group'.
The GUEST GROUP "confluence-guests-<org-name-string>" can not be saved or interacted with under /Space Permissions/Groups/ since this section is designed for 'Member Groups' only. This in turn blocks the ability to customize the default permissions for this group here.
Its also impossible to add this guest default group under /Space Permissions/Guests/ because this section only accepts 'guest users'. It doesn't allow for 'guest group' to be added.
Is there possibly another solution?
The lack of setting default permissions on this feature unfortunately kills it out of the gate, unless Im overlooking something?
Having all these guests automatically added but still requiring that we remember to go and individually customize and re-save guest permissions by user would be burdensome and unrealistic.
Hopefully Im overlooking and obvious solution! But I have looked for a couple of hours now.