|
| 1 | +# Role-Based Access Control (RBAC) |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The Status Dashboard implements RBAC for maintenance event management. Roles are extracted from the JWT `groups` claim and mapped to application permissions. |
| 6 | + |
| 7 | +## Roles |
| 8 | + |
| 9 | +Three roles are supported, with highest privilege taking precedence when a user has multiple roles: |
| 10 | + |
| 11 | +| Role | Priority | Description | |
| 12 | +|------|----------|-------------| |
| 13 | +| **sd_admins** | Highest | Full access to all operations | |
| 14 | +| **sd_operators** | Medium | Review and approve maintenance events | |
| 15 | +| **sd_creators** | Lowest | Create and manage own maintenance events | |
| 16 | + |
| 17 | +## Configuration |
| 18 | + |
| 19 | +Roles are mapped from IdP group names via environment variables: |
| 20 | + |
| 21 | +| Environment Variable | Default | Description | |
| 22 | +|---------------------|---------|-------------| |
| 23 | +| `SD_ADMINS_GROUP` | `admin-group` | IdP group for admin role | |
| 24 | +| `SD_OPERATORS_GROUP` | (none) | IdP group for operator role | |
| 25 | +| `SD_CREATORS_GROUP` | (none) | IdP group for creator role | |
| 26 | + |
| 27 | +## Permissions by Role |
| 28 | + |
| 29 | +### sd_admins |
| 30 | + |
| 31 | +- Unrestricted access to all maintenance operations |
| 32 | +- Bypass all status-based restrictions |
| 33 | +- Can transition events to any status |
| 34 | +- Events created with status `planned` (bypass review) |
| 35 | + |
| 36 | +### sd_operators |
| 37 | + |
| 38 | +- View all maintenance events regardless of status |
| 39 | +- Approve events: `pending_review` → `reviewed` |
| 40 | +- Create events with status `planned` (bypass review) |
| 41 | +- Cancel events in `pending_review` status |
| 42 | +- Update events in `pending_review` status |
| 43 | + |
| 44 | +### sd_creators |
| 45 | + |
| 46 | +- Create maintenance events (status: `pending_review`) |
| 47 | +- Modify **own** events only when status is `pending_review` |
| 48 | +- Cancel **own** events only when status is `pending_review` |
| 49 | +- Cannot modify events after approval (`reviewed`, `planned`, etc.) |
| 50 | + |
| 51 | +## Maintenance Status Workflow |
| 52 | + |
| 53 | +``` |
| 54 | +Creator creates event |
| 55 | + │ |
| 56 | + ▼ |
| 57 | + ┌─────────────┐ |
| 58 | + │pending_review│ ◄── sd_creators can modify/cancel here |
| 59 | + └──────┬──────┘ |
| 60 | + │ Operator approves |
| 61 | + ▼ |
| 62 | + ┌─────────────┐ |
| 63 | + │ reviewed │ |
| 64 | + └──────┬──────┘ |
| 65 | + │ Checker auto-transitions |
| 66 | + ▼ |
| 67 | + ┌─────────────┐ |
| 68 | + │ planned │ ◄── sd_operators/sd_admins start here |
| 69 | + └──────┬──────┘ |
| 70 | + │ |
| 71 | + ▼ |
| 72 | + [active → completed] |
| 73 | +``` |
| 74 | + |
| 75 | +## Field Visibility |
| 76 | + |
| 77 | +Some fields are only visible to authenticated users: |
| 78 | + |
| 79 | +| Field | Visibility | |
| 80 | +|-------|------------| |
| 81 | +| `creator` | Authenticated only | |
| 82 | +| `contact_email` | Authenticated only | |
| 83 | +| `version` | Authenticated only | |
| 84 | + |
| 85 | +Events with status `pending_review` or `reviewed` are hidden from unauthenticated users. |
| 86 | + |
| 87 | +## Error Responses |
| 88 | + |
| 89 | +| HTTP Code | Condition | |
| 90 | +|-----------|-----------| |
| 91 | +| `401 Unauthorized` | Missing or invalid JWT token | |
| 92 | +| `403 Forbidden` | Insufficient role permissions | |
| 93 | +| `403 Forbidden` | Attempting to modify event you don't own (sd_creators) | |
| 94 | +| `403 Forbidden` | Attempting to modify event not in `pending_review` (sd_creators) | |
| 95 | +| `409 Conflict` | Version mismatch (concurrent modification) | |
| 96 | +| `409 Conflict` | Event no longer in expected status | |
| 97 | + |
| 98 | +## JWT Token Structure |
| 99 | + |
| 100 | +The API expects JWT tokens with the following claims: |
| 101 | + |
| 102 | +```json |
| 103 | +{ |
| 104 | + "preferred_username": "user@example.com", |
| 105 | + "groups": ["sd_creators", "other-group"] |
| 106 | +} |
| 107 | +``` |
| 108 | + |
| 109 | +- `preferred_username` → stored as event creator |
| 110 | +- `groups` → matched against configured role environment variables |
0 commit comments