This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Managing Permissions with APIs

The following section describes the RemoteAuthorizationManager API and the operations that come with it. 

Permissions can be assigned to user roles. The permission is an authorization to perform a specific action on a resource. For instance, a user role can have permission (i.e., authorization) to add and delete (i.e., actions) service providers (i.e., the resource). The following set of actions can be performed on a resource.

  • get
  • add
  • delete
  • edit
  • login
  • man_config
  • man_lc_config
  • man_sec
  • up_serv
  • man_serv
  • man_media
  • mon_sys
  • del_id
  • authorize
  • inv_ser
  • ui_execute 
  • subscribe
  • publish
  • consume
  • change_permission
  • browse
  • sqs_send_message
  • sqs_receive_message
  • sqs_delete_message
  • sqs_change_message_visibility
  • sqs_get_queue_attributes

The following operations are available in this API:

authorizeRole

This function authorizes the given role to perform the specified action on the given resource.

Input parameters

ParameterDescription
roleNameThe name of the role (e.g., "role1")
resourceIdThe resource path (e.g., "/permission/admin/login")
actionThe action name of the action to be performed on the resource (e.g., "ui.execute")

Error codes

Invalid data provided
Error in connection rollback
Error! DB error occurred while checking is existing system role for :roleName & tenant id : tenantId
Error! Error occurred while getting UI permission ID for resource id : resourceId & action : action
Error! Error occurred while adding UI permission ID for resource id : resourceId & action : action
Error! Using sql : sqlStmt
Error! Error while authorizing role: roleName in permission tree for resource id: resourceId for action: action
Error! Error while denying role: roleName in permission tree for resource id: resourceId for action: action

clearAllRoleAuthorization

This function clears all authorizations of the role.

Input parameters

ParameterDescription
roleNameThe name of the role (e.g., "role1")

Error codes

Error occurred while clearing role authorizations for role : roleName

clearResourceAuthorizations

This function clears all the authorizations for the given resource.

Input parameters

ParameterDescription
resourceIdThe resource path (e.g., "/permission/admin/login")

Error codes

Error occurred while clearing resource authorizations for resource id : resourceId

clearRoleActionOnAllResources

This function removes the authorization from the role to perform the specified action on all the resources.

Input parameters

ParameterDescription
actionThe action name of the action to be performed on the resource (e.g., "ui.execute")

Error codes

Error occurred while clearing role action on all resources for role : roleName & action : action

clearRoleAuthorization

This function clear the authorization of the specified role to perform the given action on the resource.

Input parameters

ParameterDescription
roleNameThe name of the role (e.g., "role1")
resourceIdThe resource path (e.g., "/permission/admin/login")
actionThe action name of the action to be performed on the resource (e.g., "ui.execute")

Error codes

Error occurred while clearing role authorizations for role : roleName + & resource id : resourceId & action : action

denyRole

This function removes the authorization of the role to perform the given action on the specified resource.

Input parameters

ParameterDescription
roleNameThe name of the role (e.g., "role1")
resourceIdThe resource path (e.g., "/permission/admin/login")
actionThe action name of the action to be performed on the resource (e.g., "ui.execute")

Error codes 

Invalid data provided

getAllowedRolesForResource

This function retrieves the list of authorized roles to perform the given action on the specified resource.

Input parameters

ParameterDescription
resourceIdThe resource path (e.g., "/permission/admin/login")
actionThe action name of the action to be performed on the resource (e.g., "ui.execute")

Error codes

Error loading authorizations. Please check the database. Error message is + errorMessage
Error! Error while authorizing role: roleName in permission tree for resource id: resourceId for action: action
Error! Error while denying role: roleName in permission tree for resource id: resourceId for action: action

getAllowedUIResourcesForUser

This function retrieves the list of UI resources in the specified root patch for which the user has authorization. 

Input parameters

ParameterDescription
userNameThe username of the specific user (e.g., "admin")
permissionRootPathThe permission root path

Error codes

Invalid Permission root path provided
Error loading authorizations. Please check the database. Error message is message

getAllowedUIResourcesForRole

This function retrieves the list of UI resources in the specified root path for a given role

Input parameters

ParameterDescription
userNameThe name of the specific role (e.g., "admin")
permissionRootPathThe permission root path

isRoleAuthorized

This function checks whether the given role is authorized to perform the action on the specified resource.

Input parameters

ParameterDescription
roleNameThe name of the role (e.g., "role1")
resourceIdThe resource path (e.g., "/permission/admin/login")
actionThe action name of the action to be performed on the resource (e.g., "ui.execute")

Error codes 

Error loading authorizations. Please check the database. Error message is + errorMessage