Overview
Roles define collections of permissions that can be assigned to users. Each role belongs to a specific realm and contains a list of permission strings. Users inherit all permissions from their assigned roles.
Request Body
The realm identifier where this role will be created.
Unique role name within the realm.
Array of permission strings attached to this role. Permissions are arbitrary strings that define what actions this role can perform.
Response
Returns the created role object:
Array of permission strings attached to the role.
Example
curl -X POST http://localhost:8080/v1/auth/roles \
-H 'Content-Type: application/json' \
-d '{
"realm_id": "acme",
"name": "admin",
"permissions": [
"users:read",
"users:write",
"users:delete",
"reports:read"
]
}'
{
"name": "admin",
"permissions": [
"users:read",
"users:write",
"users:delete",
"reports:read"
]
}
Permission Design
Permissions are free-form strings. Common patterns include:
- Resource-action format:
resource:action (e.g., users:read, reports:write)
- Hierarchical:
service.resource.action (e.g., api.users.delete)
- Wildcard:
users:* or *:read
Error Responses
Human-readable error message when the request fails.
Common errors:
- 400 Bad Request: Invalid request format or missing required fields
- 404 Not Found: Realm does not exist
- 500 Internal Server Error: Role creation failed due to internal error