loki-mode 5.42.2 → 5.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/autonomy/app-runner.sh +684 -0
- package/autonomy/checklist-verify.py +368 -0
- package/autonomy/completion-council.sh +49 -0
- package/autonomy/loki +83 -0
- package/autonomy/playwright-verify.sh +350 -0
- package/autonomy/prd-analyzer.py +457 -0
- package/autonomy/prd-checklist.sh +223 -0
- package/autonomy/run.sh +164 -4
- package/completions/loki.bash +6 -1
- package/dashboard/__init__.py +1 -1
- package/dashboard/server.py +134 -1
- package/dashboard/static/index.html +804 -265
- package/docs/INSTALLATION.md +1 -1
- package/docs/audit-logging.md +600 -0
- package/docs/authentication.md +374 -0
- package/docs/authorization.md +455 -0
- package/docs/git-workflow.md +446 -0
- package/docs/metrics.md +527 -0
- package/docs/network-security.md +275 -0
- package/docs/openclaw-integration.md +572 -0
- package/docs/siem-integration.md +579 -0
- package/learning/__init__.py +1 -1
- package/mcp/__init__.py +1 -1
- package/memory/__init__.py +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
# Authorization Guide
|
|
2
|
+
|
|
3
|
+
Role-based access control (RBAC) for Loki Mode (v5.37.0).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Loki Mode implements a four-tier RBAC system that controls access to dashboard operations, API endpoints, and agent actions. RBAC integrates with both token-based authentication and OIDC/SSO.
|
|
8
|
+
|
|
9
|
+
## Role Definitions
|
|
10
|
+
|
|
11
|
+
### Admin
|
|
12
|
+
|
|
13
|
+
Full access to all operations and configuration.
|
|
14
|
+
|
|
15
|
+
**Scopes:** `*` (all)
|
|
16
|
+
|
|
17
|
+
**Permissions:**
|
|
18
|
+
- Start/stop/pause/resume sessions
|
|
19
|
+
- Create/update/delete tasks
|
|
20
|
+
- Modify configuration
|
|
21
|
+
- Generate/revoke tokens
|
|
22
|
+
- View audit logs
|
|
23
|
+
- Manage users and roles
|
|
24
|
+
- Access all API endpoints
|
|
25
|
+
|
|
26
|
+
**Use Cases:**
|
|
27
|
+
- System administrators
|
|
28
|
+
- DevOps engineers
|
|
29
|
+
- Project owners
|
|
30
|
+
|
|
31
|
+
### Operator
|
|
32
|
+
|
|
33
|
+
Day-to-day operations without configuration changes.
|
|
34
|
+
|
|
35
|
+
**Scopes:** `control`, `read`, `write`
|
|
36
|
+
|
|
37
|
+
**Permissions:**
|
|
38
|
+
- Start/stop/pause/resume sessions
|
|
39
|
+
- Create/update tasks
|
|
40
|
+
- View dashboard and logs
|
|
41
|
+
- Execute agent actions
|
|
42
|
+
- Access metrics endpoint
|
|
43
|
+
|
|
44
|
+
**Cannot:**
|
|
45
|
+
- Modify system configuration
|
|
46
|
+
- Manage tokens or users
|
|
47
|
+
- View audit logs (except their own actions)
|
|
48
|
+
|
|
49
|
+
**Use Cases:**
|
|
50
|
+
- Developers
|
|
51
|
+
- CI/CD pipelines
|
|
52
|
+
- Automated workflows
|
|
53
|
+
|
|
54
|
+
### Viewer
|
|
55
|
+
|
|
56
|
+
Read-only access to dashboard and logs.
|
|
57
|
+
|
|
58
|
+
**Scopes:** `read`
|
|
59
|
+
|
|
60
|
+
**Permissions:**
|
|
61
|
+
- View dashboard status
|
|
62
|
+
- View task queue
|
|
63
|
+
- View logs and events
|
|
64
|
+
- View metrics
|
|
65
|
+
- View agent activity
|
|
66
|
+
|
|
67
|
+
**Cannot:**
|
|
68
|
+
- Start/stop sessions
|
|
69
|
+
- Create/modify tasks
|
|
70
|
+
- Access audit logs
|
|
71
|
+
- Modify any state
|
|
72
|
+
|
|
73
|
+
**Use Cases:**
|
|
74
|
+
- Stakeholders
|
|
75
|
+
- Project managers
|
|
76
|
+
- External observers
|
|
77
|
+
|
|
78
|
+
### Auditor
|
|
79
|
+
|
|
80
|
+
Security and compliance monitoring.
|
|
81
|
+
|
|
82
|
+
**Scopes:** `read`, `audit`
|
|
83
|
+
|
|
84
|
+
**Permissions:**
|
|
85
|
+
- View dashboard status
|
|
86
|
+
- View task queue and logs
|
|
87
|
+
- Access audit logs
|
|
88
|
+
- View agent action history
|
|
89
|
+
- Export compliance reports
|
|
90
|
+
|
|
91
|
+
**Cannot:**
|
|
92
|
+
- Start/stop sessions
|
|
93
|
+
- Create/modify tasks
|
|
94
|
+
- Modify configuration
|
|
95
|
+
|
|
96
|
+
**Use Cases:**
|
|
97
|
+
- Security teams
|
|
98
|
+
- Compliance officers
|
|
99
|
+
- Internal auditors
|
|
100
|
+
|
|
101
|
+
## Configuration
|
|
102
|
+
|
|
103
|
+
### Enable RBAC
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
export LOKI_RBAC_ENABLED=true
|
|
107
|
+
loki start ./prd.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Assign Roles via Tokens
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Generate token with role
|
|
114
|
+
loki enterprise token generate dev-1 --role operator --expires 30
|
|
115
|
+
loki enterprise token generate viewer-1 --role viewer --expires 90
|
|
116
|
+
loki enterprise token generate auditor-1 --role auditor --expires 180
|
|
117
|
+
loki enterprise token generate admin-1 --role admin --expires 365
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Configuration File
|
|
121
|
+
|
|
122
|
+
```yaml
|
|
123
|
+
# .loki/config.yaml
|
|
124
|
+
enterprise:
|
|
125
|
+
rbac:
|
|
126
|
+
enabled: true
|
|
127
|
+
default_role: viewer # Default for OIDC users without role mapping
|
|
128
|
+
enforce_mfa: false # Require MFA for admin role (future)
|
|
129
|
+
roles:
|
|
130
|
+
admin:
|
|
131
|
+
scopes: ["*"]
|
|
132
|
+
operator:
|
|
133
|
+
scopes: ["control", "read", "write"]
|
|
134
|
+
viewer:
|
|
135
|
+
scopes: ["read"]
|
|
136
|
+
auditor:
|
|
137
|
+
scopes: ["read", "audit"]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### OIDC Role Mapping
|
|
141
|
+
|
|
142
|
+
Map OIDC claims to Loki roles:
|
|
143
|
+
|
|
144
|
+
```yaml
|
|
145
|
+
enterprise:
|
|
146
|
+
rbac:
|
|
147
|
+
oidc_role_mapping:
|
|
148
|
+
# Map Google Groups to roles
|
|
149
|
+
google:
|
|
150
|
+
admins@example.com: admin
|
|
151
|
+
devops@example.com: operator
|
|
152
|
+
viewers@example.com: viewer
|
|
153
|
+
# Map Azure AD groups to roles
|
|
154
|
+
azure:
|
|
155
|
+
12345678-abcd-1234-abcd-123456789abc: admin # Group Object ID
|
|
156
|
+
87654321-dcba-4321-dcba-987654321cba: operator
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Scope-Based Access Control
|
|
160
|
+
|
|
161
|
+
### Scope Hierarchy
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
* (all)
|
|
165
|
+
├── control
|
|
166
|
+
│ ├── write
|
|
167
|
+
│ │ └── read
|
|
168
|
+
│ └── read
|
|
169
|
+
├── audit
|
|
170
|
+
│ └── read
|
|
171
|
+
└── read
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Scopes are additive:
|
|
175
|
+
- `control` automatically includes `write` and `read`
|
|
176
|
+
- `write` automatically includes `read`
|
|
177
|
+
- `audit` requires separate grant (not included in `*`)
|
|
178
|
+
|
|
179
|
+
### Endpoint Permissions
|
|
180
|
+
|
|
181
|
+
| Endpoint | Required Scope | Roles with Access |
|
|
182
|
+
|----------|----------------|-------------------|
|
|
183
|
+
| `GET /api/status` | `read` | All roles |
|
|
184
|
+
| `GET /api/tasks` | `read` | All roles |
|
|
185
|
+
| `GET /api/logs` | `read` | All roles |
|
|
186
|
+
| `GET /metrics` | `read` | All roles |
|
|
187
|
+
| `POST /api/tasks` | `write` | Operator, Admin |
|
|
188
|
+
| `PATCH /api/tasks/:id` | `write` | Operator, Admin |
|
|
189
|
+
| `POST /api/control/start` | `control` | Operator, Admin |
|
|
190
|
+
| `POST /api/control/stop` | `control` | Operator, Admin |
|
|
191
|
+
| `GET /api/audit` | `audit` | Auditor, Admin |
|
|
192
|
+
| `POST /api/enterprise/tokens` | `*` | Admin only |
|
|
193
|
+
| `DELETE /api/enterprise/tokens/:id` | `*` | Admin only |
|
|
194
|
+
| `POST /api/config` | `*` | Admin only |
|
|
195
|
+
|
|
196
|
+
## Custom Roles
|
|
197
|
+
|
|
198
|
+
Define custom roles for specific use cases:
|
|
199
|
+
|
|
200
|
+
```yaml
|
|
201
|
+
# .loki/config.yaml
|
|
202
|
+
enterprise:
|
|
203
|
+
rbac:
|
|
204
|
+
custom_roles:
|
|
205
|
+
# Read-only with metrics access
|
|
206
|
+
metrics_viewer:
|
|
207
|
+
scopes: ["read"]
|
|
208
|
+
description: "View metrics and dashboard only"
|
|
209
|
+
|
|
210
|
+
# Task management only
|
|
211
|
+
task_manager:
|
|
212
|
+
scopes: ["read", "write"]
|
|
213
|
+
description: "Create and update tasks, no session control"
|
|
214
|
+
|
|
215
|
+
# Security analyst
|
|
216
|
+
security_analyst:
|
|
217
|
+
scopes: ["read", "audit"]
|
|
218
|
+
description: "View audit logs and security events"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Generate token with custom role:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
loki enterprise token generate metrics-bot --role metrics_viewer
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Permission Checks
|
|
228
|
+
|
|
229
|
+
### CLI
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# Check current permissions
|
|
233
|
+
loki enterprise rbac check
|
|
234
|
+
|
|
235
|
+
# Check specific permission
|
|
236
|
+
loki enterprise rbac check --scope control
|
|
237
|
+
|
|
238
|
+
# List permissions for role
|
|
239
|
+
loki enterprise rbac permissions --role operator
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### API
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Check token permissions
|
|
246
|
+
curl -H "Authorization: Bearer $LOKI_TOKEN" \
|
|
247
|
+
http://localhost:57374/api/enterprise/rbac/check
|
|
248
|
+
|
|
249
|
+
# Response:
|
|
250
|
+
{
|
|
251
|
+
"role": "operator",
|
|
252
|
+
"scopes": ["control", "read", "write"],
|
|
253
|
+
"permissions": {
|
|
254
|
+
"can_start_session": true,
|
|
255
|
+
"can_stop_session": true,
|
|
256
|
+
"can_create_tasks": true,
|
|
257
|
+
"can_modify_config": false,
|
|
258
|
+
"can_manage_tokens": false
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Agent Action Authorization
|
|
264
|
+
|
|
265
|
+
Control which roles can trigger agent actions:
|
|
266
|
+
|
|
267
|
+
```yaml
|
|
268
|
+
enterprise:
|
|
269
|
+
rbac:
|
|
270
|
+
agent_actions:
|
|
271
|
+
git_commit:
|
|
272
|
+
required_scope: control
|
|
273
|
+
cli_invoke:
|
|
274
|
+
required_scope: control
|
|
275
|
+
file_write:
|
|
276
|
+
required_scope: write
|
|
277
|
+
file_read:
|
|
278
|
+
required_scope: read
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Environment Variables
|
|
282
|
+
|
|
283
|
+
| Variable | Default | Description |
|
|
284
|
+
|----------|---------|-------------|
|
|
285
|
+
| `LOKI_RBAC_ENABLED` | `false` | Enable RBAC system |
|
|
286
|
+
| `LOKI_RBAC_DEFAULT_ROLE` | `viewer` | Default role for OIDC users |
|
|
287
|
+
| `LOKI_RBAC_STRICT_MODE` | `false` | Deny access when role is undefined (vs default to viewer) |
|
|
288
|
+
| `LOKI_RBAC_AUDIT_CHECKS` | `true` | Log all permission checks to audit log |
|
|
289
|
+
|
|
290
|
+
## Examples
|
|
291
|
+
|
|
292
|
+
### Multi-Environment Setup
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Production - strict RBAC
|
|
296
|
+
export LOKI_RBAC_ENABLED=true
|
|
297
|
+
export LOKI_RBAC_STRICT_MODE=true
|
|
298
|
+
export LOKI_RBAC_DEFAULT_ROLE=viewer
|
|
299
|
+
|
|
300
|
+
# Development - relaxed RBAC
|
|
301
|
+
export LOKI_RBAC_ENABLED=false
|
|
302
|
+
|
|
303
|
+
# Staging - moderate RBAC
|
|
304
|
+
export LOKI_RBAC_ENABLED=true
|
|
305
|
+
export LOKI_RBAC_DEFAULT_ROLE=operator
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Team-Based Access
|
|
309
|
+
|
|
310
|
+
```yaml
|
|
311
|
+
# .loki/config.yaml
|
|
312
|
+
enterprise:
|
|
313
|
+
rbac:
|
|
314
|
+
oidc_role_mapping:
|
|
315
|
+
google:
|
|
316
|
+
engineering@company.com: operator
|
|
317
|
+
qa@company.com: operator
|
|
318
|
+
product@company.com: viewer
|
|
319
|
+
security@company.com: auditor
|
|
320
|
+
devops@company.com: admin
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Service Account Tokens
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# CI/CD pipeline token
|
|
327
|
+
loki enterprise token generate github-actions \
|
|
328
|
+
--role operator \
|
|
329
|
+
--scopes "control,read,write" \
|
|
330
|
+
--expires 365
|
|
331
|
+
|
|
332
|
+
# Monitoring system token
|
|
333
|
+
loki enterprise token generate datadog \
|
|
334
|
+
--role viewer \
|
|
335
|
+
--scopes "read" \
|
|
336
|
+
--expires 9999
|
|
337
|
+
|
|
338
|
+
# Security scanner token
|
|
339
|
+
loki enterprise token generate security-scanner \
|
|
340
|
+
--role auditor \
|
|
341
|
+
--scopes "read,audit" \
|
|
342
|
+
--expires 180
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Best Practices
|
|
346
|
+
|
|
347
|
+
### Principle of Least Privilege
|
|
348
|
+
|
|
349
|
+
1. Start with minimal permissions (viewer role)
|
|
350
|
+
2. Grant additional scopes only as needed
|
|
351
|
+
3. Use custom roles for specific use cases
|
|
352
|
+
4. Review and audit role assignments quarterly
|
|
353
|
+
5. Remove unused tokens immediately
|
|
354
|
+
|
|
355
|
+
### Role Assignment
|
|
356
|
+
|
|
357
|
+
1. Use OIDC role mapping for human users
|
|
358
|
+
2. Use token-based roles for automation
|
|
359
|
+
3. Separate production and development roles
|
|
360
|
+
4. Document role assignments and justifications
|
|
361
|
+
5. Rotate credentials regularly
|
|
362
|
+
|
|
363
|
+
### Auditing
|
|
364
|
+
|
|
365
|
+
1. Enable `LOKI_RBAC_AUDIT_CHECKS` to log permission checks
|
|
366
|
+
2. Review audit logs for unauthorized access attempts
|
|
367
|
+
3. Monitor for privilege escalation attempts
|
|
368
|
+
4. Alert on admin role usage in production
|
|
369
|
+
5. Generate compliance reports monthly
|
|
370
|
+
|
|
371
|
+
## Troubleshooting
|
|
372
|
+
|
|
373
|
+
### Permission Denied Errors
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# Check token role and scopes
|
|
377
|
+
loki enterprise token list
|
|
378
|
+
|
|
379
|
+
# Verify required scope for operation
|
|
380
|
+
loki enterprise rbac permissions --role <your-role>
|
|
381
|
+
|
|
382
|
+
# Check audit log for denial reason
|
|
383
|
+
loki enterprise audit tail --event permission.denied
|
|
384
|
+
|
|
385
|
+
# Generate new token with correct role
|
|
386
|
+
loki enterprise token revoke <old-token>
|
|
387
|
+
loki enterprise token generate <name> --role operator
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### OIDC Role Mapping Not Working
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
# Verify OIDC claims contain group information
|
|
394
|
+
# Check identity provider configuration
|
|
395
|
+
|
|
396
|
+
# Test with explicit token role first
|
|
397
|
+
loki enterprise token generate test-admin --role admin
|
|
398
|
+
|
|
399
|
+
# Check RBAC configuration
|
|
400
|
+
cat .loki/config.yaml | grep -A 10 rbac
|
|
401
|
+
|
|
402
|
+
# View OIDC claims in audit log
|
|
403
|
+
loki enterprise audit tail --event auth.oidc.success
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Scope Confusion
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
# List all scopes for a role
|
|
410
|
+
loki enterprise rbac permissions --role operator
|
|
411
|
+
|
|
412
|
+
# Check if scope is implied by hierarchy
|
|
413
|
+
# control -> write -> read
|
|
414
|
+
# audit (separate, not included in control)
|
|
415
|
+
|
|
416
|
+
# Test specific permission
|
|
417
|
+
curl -H "Authorization: Bearer $TOKEN" \
|
|
418
|
+
http://localhost:57374/api/enterprise/rbac/check?scope=control
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
## Migration Guide
|
|
422
|
+
|
|
423
|
+
### Upgrading from Token-Only to RBAC
|
|
424
|
+
|
|
425
|
+
1. Enable RBAC in audit mode first:
|
|
426
|
+
```bash
|
|
427
|
+
export LOKI_RBAC_ENABLED=true
|
|
428
|
+
export LOKI_RBAC_STRICT_MODE=false # Allow during migration
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
2. Assign roles to existing tokens:
|
|
432
|
+
```bash
|
|
433
|
+
for token in $(loki enterprise token list --format json | jq -r '.[].id'); do
|
|
434
|
+
loki enterprise token update $token --role operator
|
|
435
|
+
done
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
3. Test permissions:
|
|
439
|
+
```bash
|
|
440
|
+
loki enterprise rbac check
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
4. Enable strict mode:
|
|
444
|
+
```bash
|
|
445
|
+
export LOKI_RBAC_STRICT_MODE=true
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
5. Monitor audit logs for denials and adjust roles as needed.
|
|
449
|
+
|
|
450
|
+
## See Also
|
|
451
|
+
|
|
452
|
+
- [Authentication Guide](authentication.md) - Token and OIDC setup
|
|
453
|
+
- [Audit Logging](audit-logging.md) - Track permission checks
|
|
454
|
+
- [Enterprise Features](../wiki/Enterprise-Features.md) - Complete enterprise guide
|
|
455
|
+
- [Network Security](network-security.md) - Additional security controls
|