Search code examples
cumulocity

Check Permissions with REST/Java in Cumulocity


is there an efficient way to check if an user has access to an managed object by comparing his effective inventory roles with a list of managed objects maybe? Or do I have to check each managed object with an API call?

Regards Stefan


Solution

  • There is an API that will give you the inventory roles for a user

    /user/{{tenant}}/users/{{username}}/roles/inventory
    

    However keep in mind that the IDs listed in the response are the groups that the user has access to and not the full list of devices. You will still need to check what devices are in the groups and potentially run through the hierarchy.

    Another method would be just to query all devices with the credentials of the user. This of course requires that you can query in the context of the user.