Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

...

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

    Code Block
    themeMidnight
    --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":

    Code Block
    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:

    Code Block
    themeMidnight
    --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":

    Code Block
    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:

    Code Block
    themeMidnight
    --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":

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


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

    Code Block
    themeMidnight
    --action runFromCsv --file groupspaces.csv --common "--action removeAllPermissionsForGroup removePermissions --permissions @all"


Info
  • 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.

...