Allow administrators to edit a restricted page

Olivier Crozier February 4, 2014

Hello,

In the opposite of some other questions, it there any "automated" or "general configuration" way to allow an administrator to change the restriction on a confluence page?

Let me explain...

Due to some infrastructure change we might need to update several pages on a confluence with the help of a script. There are different solutions based on the Confluence CLI or with python.

However the page edit fails if the page is restricted.

An administrator can view a restricted page (as long as he knows the url) and even change the restriction on this page in order to allow himself to edit its content. He can also remove this permission then after.

Conclusion: An administrator can change the page permission on a restricted page via the GUI. Is there any equivalent solution with script? Alternativaly is there any general configuration that would allow an administrator to edit every page?

Thanks in advance,
Best regards,
Olivier

3 answers

1 accepted

0 votes
Answer accepted
Olivier Crozier February 4, 2014

Eventually I found the python solution thanks to the https://developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods.

pageperms = client.confluence2.getContentPermissionSet(token, page['id'], 'Edit');

    tmppageperms = copy.deepcopy(pageperms)
    for contentPermission in tmppageperms['contentPermissions']:
        if contentPermission['userName'] == user:
            break;
    if ('contentPermission' not in locals() or contentPermission['userName'] != user):
        tmppageperms['contentPermissions'].append({'userName': user, 'type': 'Edit'})

    client.confluence2.setContentPermissions(token, page['id'], 'Edit', tmppageperms['contentPermissions']);
    raw_input('Press Enter to continue...')
    client.confluence2.setContentPermissions(token, page['id'], 'Edit', pageperms['contentPermissions']);

To be combined with the update page routine as described in this other article https://answers.atlassian.com/questions/104580/how-to-update-a-page-from-python.

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
February 4, 2014

Using Confluence Command Line Interface and the addPermissions action:

confluence --action addPermissions --space Experiment --title myPage --permissions view,edit --userId automation

Olivier Crozier February 4, 2014

Ah yes I did not see this action. Thanks for the info.

The thing is I started with a python script and I discovered later that Confluence CLI can also update the page content (eg getSource+storePage).

I'm sure there's a solution with python but I could not find it.

0 votes
Steve Gerstner [bridgingIT]
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.
February 4, 2014
  1. You can download a xml export of your space.
  2. Then edit it witth a script
  3. Delete the space
  4. Upload your modified export

Regards

Steve

Olivier Crozier February 4, 2014

Thanks you Steve for this other solution.

I think it's a bit tricky to delete a space so I would rather avoid this.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events