You can retrieve the user’s “highest role” for the currently logged in user. As far as I remember, there’s currently no way to get all roles for any user.
As for permissions, roles are currently static so there are no permissions, just ACLs. In 0.8.19, the access rules are slightly configurable through runtime configuration (openboxes-config.groovy). See openboxes.security.rbac.rules
in Config.groovy for more information.
openboxes.security.rbac.rules = [
[controller: '*', actions: ['delete'], accessRules: [ minimumRequiredRole: RoleType.ROLE_SUPERUSER ]],
[controller: '*', actions: ['remove'], accessRules: [ minimumRequiredRole: RoleType.ROLE_SUPERUSER ]],
[controller: '*', actions: ['removeItem'], accessRules: [ minimumRequiredRole: RoleType.ROLE_MANAGER ]],
[controller: 'order', actions: ['remove'], accessRules: [ minimumRequiredRole: RoleType.ROLE_ASSISTANT ]],
[controller: 'order', actions: ['removeOrderItem'], accessRules: [ minimumRequiredRole: RoleType.ROLE_MANAGER ]],
...
]
However, moving to a more dynamic role / permission mapping (i.e. allow system admins to configure roles and permissions in the database) will need to wait until we finish our migration to Grails 3.
And finally, here’s how to request the “highest role” data point from the API.
Request
GET https://<your-hostname>/openboxes/api/getAppContext
Response
{
"data":{
"user":{
"id":"3",
"name":"Justin Miranda",
"firstName":"Justin",
"lastName":"Miranda",
"email":"justin@openboxes.com",
"username":"jmiranda"
},
"location":{
"id":"8a8a9e9665c4f59d0165c54ec6b10027",
"name":"Distribution Center",
// The following data was omitted for the sake of brevity
// ...
},
"isSuperuser":true,
"isUserAdmin":true,
"supportedActivities":[
"SEND_STOCK",
"EXTERNAL",
"ADJUST_INVENTORY",
"RECEIVE_STOCK",
"REQUIRE_ACCOUNTING",
"MANAGE_INVENTORY",
"PICK_STOCK",
"FULFILL_REQUEST",
"PLACE_REQUEST",
"PUTAWAY_STOCK"
],
"grailsVersion":"1.3.9",
"appVersion":"0.8.19",
"branchName":"master",
"buildNumber":"v0.8.19",
"environment":"production",
"buildDate":"31 Aug 2022 08:14:01 PM",
"ipAddress":"<redacted>",
"hostname":"<redacted>",
"timezone":"GMT",
"activeLanguage":"en",
"highestRole":"Superuser",
"currencyCode":"USD",
"localizedHelpScoutKey":"<redacted>",
"isHelpScoutEnabled":true
}
}