Skip to content

UI should check roles/permissions before allow actions to a user #244

@ctron

Description

@ctron

For example, the upload. The user has an access token of:

{
  "exp": 1731661671,
  "iat": 1731661371,
  "auth_time": 1731661290,
  "jti": "d36fce31-b1ec-4568-a7db-29b3d4ff59ad",
  "iss": "https://trustify-sso.dentrassi.de/realms/trustify",
  "aud": "account",
  "sub": "5049d7ed-4035-4be8-a23e-6e5d1e30f4e3",
  "typ": "Bearer",
  "azp": "frontend",
  "session_state": "4167ef65-8290-41a6-9023-7ee1627922f5",
  "allowed-origins": [
    "*"
  ],
  "realm_access": {
    "roles": [
      "default-roles-trustify",
      "offline_access",
      "chicken-user",
      "uma_authorization"
    ]
  },
  "resource_access": {
    "account": {
      "roles": [
        "manage-account",
        "manage-account-links",
        "view-profile"
      ]
    }
  },
  "scope": "openid email profile read:document",
  "sid": "4167ef65-8290-41a6-9023-7ee1627922f5",
  "email_verified": false,
  "name": "Jens Reimann",
  "preferred_username": "ctron",
  "given_name": "Jens",
  "family_name": "Reimann",
  "email": "ctron@dentrassi.de"
}

The important part being: .scope = "… read:document". Missing create: or update: scopes. So it's read-only.

Still, the UI offers an upload screen, which then fails with a 403.

I think there should be an enpoint in the backend which the UI can use to check if an operation possible for the user. As the scope read:document is specific to the keycloak setup. Which translates to the read:advisory and read:sbom permission. However, that information/logic is unknown to the client. And differs between different OIDC providers (like AWS cognito).

My proposal would be to create an endpoint where the frontend can check if a permission is granted or not. Sending the bearer token and the requested permission. Which are, right now, defined by: https://github.com/trustification/trustify/blob/ed72d871cd9a9d2afe6ce30380d0bbd5edf7b497/common/auth/src/permission.rs#L57-L110

Metadata

Metadata

Labels

kind/bugCategorizes issue or PR as related to a bug.needs-priorityIndicates an issue or PR lacks a `priority/foo` label and requires one.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions