Skip to end of banner
Go to start of banner

How to replace group permissions with individual permissions in spaces using Confluence Command Line Interface (CLI)

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

This article explains how to replace group permissions with individual permissions in spaces using Confluence Command Line Interface (CLI).

Instructions

  1. Run the below CLI command to get CSV file of all space permissions:

    --action runFromSpaceList  --common "--action getSpacePermissionList --file permissions.csv --append"
  2. Import the above "permissions.csv" to SQL database table named "spacepermissions". Be sure to preserve the column names.
  3. Export the below SQL query output to a CSV file (with column headers) named "groups.csv":

    select distinct Id as `group` from confluence.spacepermissions where `Id Type` = 'group'


  4. Run the below CLI command to create a list of users for the groups:

    --action runFromGroupList --file groups.csv --common "--action getUserList --columns \"1,2,3\" --file spaceusers.csv --append"


  5. Import the above "spaceusers.csv" to an SQL database table named "spaceusers". Be sure to preserve the column names.
  6. Export the below SQL query output to a CSV (with column headers) file named "spaceuserpermissions.csv":

    select distinct space,User as "userId", concat_ws(',',
    if(`View`='Yes','VIEWSPACE',''),
    if(`Delete Own`='Yes','REMOVEOWNCONTENT',''),
    if(`Pages Add`='Yes','EDITSPACE',''),
    if(`Pages Delete`='Yes','REMOVEPAGE',''),
    if(`Blog Add`='Yes','EDITBLOG',''),
    if(`Blog Delete`='Yes','REMOVEBLOG',''),
    if(`Attachments Add`='Yes','CREATEATTACHMENT',''),
    if(`Attachments Delete`='Yes','REMOVEATTACHMENT',''),
    if(`Comments Add`='Yes','COMMENT',''),
    if(`Comments Remove`='Yes','REMOVECOMMENT',''),
    if(`Restrictions`='Yes','SETPAGEPERMISSIONS',''),
    if(`Mail Delete`='Yes','REMOVEMAIL',''),
    if(`Space Export`='Yes','EXPORTSPACE',''),
    if(`Admin`='Yes','SETSPACEPERMISSIONS','')
    ) as "permissions"
    from confluence.spacepermissions, confluence.spaceusers 
    where confluence.spacepermissions.Id = confluence.spaceusers.User and confluence.spacepermissions.`Id Type` = 'user'


  7. Run the following CLI command to add user permissions:

    --action runFromCsv --file "spaceuserpermissions.csv" --common "--action addPermissions"


  8. Export the below SQL query output to a CSV file (with column headers) named "groupspaces.csv":

    select distinct Space, Id as "group" from confluence.spacepermissions where `Id Type` = 'group'


  9. Run the following CLI command to remove group permissions:

    --action runFromCsv --file groupspaces.csv --common "--action removePermissions --permissions @all"
  • It is recommended to test the commands in a non-production environment or run the action with --simulate parameter to verify the behavior before deploying.
  • The use of sample or demo SQL databases are recommended for importing CSV files.
  • SQL quires mentioned in the article refers to mysql database and modify the queries according to other SQL databases.
  • No labels