Skip to content

API: User permissions object doesn't take groups into account #18172

@Iizuki

Description

@Iizuki

Summary

The user permissions object acquired e.g. from GET /users/me API endpoint doesn't directly tell what permissions the user has. Rights inherited from groups are not visible here.

Example

A trimmed example of the returned object:

{
  "superuser": 0,
  "admin": 0,
  "import": 0,
  "reports.view": 0,
  "assets.view": 1,
  "assets.create": 1,
  "assets.edit": 1,
  "assets.delete": 1,
  "assets.checkin": 1,
  "assets.checkout": 1,
  "assets.audit": 1,
  "assets.view.requestable": 1,
  "assets.view.encrypted_custom_fields": -1,
  "accessories.view": -1,
  ...
}

My expectation was that the values were booleans serialized as 1/0, but then I discovered that it can be -1 too. So in fact the legend is:

Value Meaning
1 Grant
0 Inherit
-1 Deny

I.e. just encoding what you can see in the user settings. This is not documented.

The issue

This is unexpected, and not really useful either. Zeroes (which are really common in the wild) don't tell whether the user has the right or not.

Solutions

Some ideas how to improve the API.

Return resolved permissions

Resolve the inherited permissions serverside and just return booleans. I don't think API users really care which way the permission came through.

This would be my preference.

Use an enum instead

Return unresolved permissions just as now, but serialize them into an enum that makes it clear what's going on. For example: "grant", "inherit" and "deny".

Sub-issues

Metadata

Metadata

Assignees

Labels

Projects

Status

In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions