onelogin / onelogin-python-sdk

36 stars 37 forks source link

Issue with 'create_privilege' function #86

Closed Tommy-Lightning closed 1 year ago

Tommy-Lightning commented 1 year ago

Using the 'create_privilege' function from the PrivilegesApi class does not post data to the API properly. For example, using the example given in the documentation:

{"name":"User Helpdesk","description":"Can administer helpdesk users","privilege":{"Version":"2018-05-18","Statement":[{"Effect":"Allow","Action":["users:List","users:Get","users:Unlock","users:ResetPassword","users:GenerateTempMfaToken"],"Scope":["*"]}]}}

The following response is given when using the SDK:

Exception when calling PrivilegesApi->list_priveleges: 1 validation error for PrivilegePrivilegeStatementInner Action each list item must be one of ('Apps:Create', 'Apps:Delete', 'Apps:List', 'Apps:Get', 'Apps:Update', 'Apps:ManageConnectors', 'Apps:ManageRoles', 'Apps:ManageTabs', 'Apps:ManageUsers', 'Apps:ReapplyMappings', 'Users:Create', 'Users:Delete', 'Users:List', 'Users:Get', 'Users:Update', 'Users:AssumeUser', 'Users:ManageApps', 'Users:Unlock', 'Users:GenerateTempMfaToken', 'Users:ResetPassword', 'Users:ReapplyMappings', 'Users:ManageLicense', 'Users:Invite', 'Users:ManageRoles', 'Roles:Create', 'Roles:Get', 'Roles:List', 'Roles:Update', 'Roles:Delete', 'Roles:ManageUsers', 'Roles:ManageApps', 'Reports:Create', 'Reports:Get', 'Reports:List', 'Reports:Update', 'Reports:Delete', 'Reports:Clone', 'Events:Get', 'Events:List', 'Groups:Create', 'Groups:Get', 'Groups:List', 'Groups:Update', 'Groups:Delete', 'Policies:Create', 'Policies:Get', 'Policies:List', 'Policies:Update', 'Policies:Delete', 'Policies:SetDefault') (type=value_error)

This error is consistent when trying to assign Apps, Users, Roles, Reports, Events, Groups and Policies when creating a privilege. Also allowing 'all' in the format [*] give a similar output.

Jmfwolf commented 1 year ago

Thank you for bringing this to my attention. I will keep you updated as I correct these issues

Jmfwolf commented 1 year ago

The issue should be resolved. So long as you have sufficient access to the privileges endpoint

Jmfwolf commented 1 year ago

Please try the pre-release https://github.com/onelogin/onelogin-python-sdk/releases/tag/3.1.6