Skip to main content

Permissions API

Authorization check endpoints and permission management. YorAuth uses a resource:action permission model where wildcards are supported (posts:*, *:read, *:*).

Permission checks are cached in Redis with a 1-hour TTL and invalidated automatically when role or permission assignments change.

Authentication

All endpoints require a valid JWT access token:

text
Authorization: Bearer {access_token}

Check Permission

GET /api/v1/applications/{applicationId}/authz/check

POST /api/v1/applications/{applicationId}/authz/check

Check whether a user has a specific permission. Use GET for simple RBAC checks or POST when passing resource and context attributes for ABAC policy evaluation.

Authentication

Requires jwt.permission:authz:check.

Parameters (GET — query string, or POST — request body)

FieldTypeRequiredDescription
user_idstringYesThe user to check
permissionstringYesPermission in resource:action format (e.g., posts:read, users:*)
resourceobjectNoResource attributes for ABAC evaluation (e.g., {"owner_id": "user_123"})
contextobjectNoRequest context for ABAC evaluation (e.g., {"ip": "1.2.3.4", "time": "09:00"})

Response — RBAC only

200 OK

json
{
  "allowed": true,
  "permission": "posts:read",
  "cached": true
}

Response — With ABAC evaluation

200 OK

json
{
  "allowed": true,
  "permission": "posts:update",
  "cached": false,
  "abac_evaluated": true,
  "policies_checked": 2
}

Error Responses

StatusCodeDescription
400VALIDATION_INVALID_FORMATPermission does not match resource:action format

Bulk Check Permissions

POST /api/v1/applications/{applicationId}/authz/check-bulk

Check multiple permissions for a user in a single request. Returns a result for each permission. Supports up to 50 permissions per request.

Authentication

Requires jwt.permission:authz:check.

Request Body

FieldTypeRequiredDescription
user_idstringYesThe user to check
permissionsarray of stringsYes1–50 permissions in resource:action format
resourceobjectNoResource attributes for ABAC evaluation
contextobjectNoRequest context for ABAC evaluation

Response

200 OK

json
{
  "user_id": "550e8400-e29b-41d4-a716-446655440000",
  "results": {
    "posts:read": true,
    "posts:create": true,
    "posts:delete": false,
    "users:read": false
  }
}

Error Responses

StatusCodeDescription
400VALIDATION_INVALID_FORMATOne or more permissions are malformed

Permissions are defined inline when creating or updating roles — there is no separate endpoint to create a standalone permission. A permission is automatically created the first time it appears in a role definition. Use the Roles API to manage permission assignments to roles.


Permission Format

Permissions follow the resource:action pattern. Both parts support the * wildcard:

PermissionMeaning
posts:readRead posts only
posts:*All actions on posts
*:readRead access on all resources
*:*All permissions (superuser)

When creating roles, permissions are validated against this pattern:

text
/^[a-zA-Z0-9_*-]+:[a-zA-Z0-9_*-]+$/

Examples of valid permission strings:

  • users:read
  • billing:manage
  • reports:export
  • posts:*
  • *:read