Allow administrators to edit a restricted page

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

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.

  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

Thanks you Steve for this other solution.

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

Using Confluence Command Line Interface and the addPermissions action:

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

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.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

271 views 11 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you