# CHANGE THIS VARIABLE IF YOUR CLI IS IN A DIFFERENT LOCATION
# get cli location from properties
clidir='/opt/sas/viya/home/bin/'
propertylist=getapplicationproperties()
#clidir='c:\\admincli\\'
clidir=propertylist["sascli.location"]
cliexe=propertylist["sascli.executable"]
# setup command-line arguements
clicommand=os.path.join(clidir,cliexe)
# setup command-line arguements
parser=argparse.ArgumentParser(description="Apply bulk auths from a CSV file to folders and contents")
parser=argparse.ArgumentParser(description="Apply bulk auths from a CSV file to folders and contents")
parser.add_argument("-f","--file",help="Full path to CSV file. Format of csv: 'folderpath,principaltype,principalid,grant_or_prohibit,perms_on_folder,perms_on_contents",required='True')
parser.add_argument("-f","--file",help="Full path to CSV file. Format of csv: 'folderpath,principaltype,principalid,grant_or_prohibit,perms_on_folder,perms_on_contents",required='True')
args=parser.parse_args()
args=parser.parse_args()
@ -74,14 +78,14 @@ if check:
folderid=getfolderid(folderpath)
folderid=getfolderid(folderpath)
folderuri=folderid[0]
folderuri=folderid[0]
reqval='/folders/folders/'+folderuri
reqval='/folders/folders/'+folderuri
# Construct JSON objects from auth rules defined in CSV. Two JSON objects are created for each row of CSV; one for perms on the folder object, one for conveyed perms on the object's contents.
# Construct JSON objects from auth rules defined in CSV. Two JSON objects are created for each row of CSV; one for perms on the folder object, one for conveyed perms on the object's contents.
value_dict_object={"description":"Created by applyfolderauthorizations.py",
value_dict_object={"description":"Created by applyfolderauthorizations.py",
"objectUri":reqval,
"objectUri":reqval,
"permissions":folderpermissions.split(','),
"permissions":folderpermissions.split(','),
"principalType":principaltype,
"principalType":principaltype,
"principal":principalname,
"principal":principalname,
"type":accesssetting
"type":accesssetting
}
}
value_dict_container={"description":"Created by applyfolderauthorizations.py",
value_dict_container={"description":"Created by applyfolderauthorizations.py",
# This tool explains the permissions of any object.
# This tool explains the permissions of any object.
@ -161,7 +170,7 @@ else:
else:
else:
convey=False
convey=False
#Use the /authorization/decision endpoint to ask for an explanation of the rules that are relevant to principals on this URI
#Use the /authorization/decision endpoint to ask for an explanation of the rules that are relevant to principals on this URI
#See Authorization API documentation in swagger at http://swagger.na.sas.com/apis/authorization/v4/apidoc.html#op:createExplanation
#See Authorization API documentation in swagger at http://swagger.na.sas.com/apis/authorization/v4/apidoc.html#op:createExplanation
endpoint='/authorization/decision'
endpoint='/authorization/decision'
@ -215,7 +224,7 @@ for pi in e:
# Permissions on object
# Permissions on object
forpermissioninpermissions:
forpermissioninpermissions:
# Not all objects have all the permissions
# Not all objects have all the permissions
# Note that some objects do have permissions which are not meaningful for that object.
# Note that some objects do have permissions which are not meaningful for that object.
# E.g. SASAdministrators are granted Add and Remove on reports, by an OOTB rule which grants SASAdministrators all permissions (including Add and Remove) on /**.
# E.g. SASAdministrators are granted Add and Remove on reports, by an OOTB rule which grants SASAdministrators all permissions (including Add and Remove) on /**.
# Meanwhile, Add and Remove are not shown in the View or Edit Authotizations dialogs for reports in EV etc.
# Meanwhile, Add and Remove are not shown in the View or Edit Authotizations dialogs for reports in EV etc.
# So, while it may be correct for the /authorization/decisions endpoint to explain that SASAdministrators are granted Add and Remove on a report,
# So, while it may be correct for the /authorization/decisions endpoint to explain that SASAdministrators are granted Add and Remove on a report,
@ -271,7 +280,7 @@ for pi in e:
else:
else:
# This permission was absent from the expanation for this principal
# This permission was absent from the expanation for this principal