Feat v0.7.7 api tokens ext permissions (#61)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m48s
CI/CD / test-sqlite (push) Successful in 2m49s
CI/CD / build-and-deploy (push) Successful in 28s

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #61.
This commit is contained in:
2026-04-02 19:11:47 +00:00
committed by xcaliber
parent e02b13dc12
commit e4f0bdbd36
34 changed files with 1769 additions and 58 deletions

View File

@@ -2,6 +2,42 @@
All notable changes to Armature are documented here.
## v0.7.7 — API Tokens + Extension Permissions
Personal access tokens (PATs) for programmatic API access, plus extension-declared
user permissions for backend RBAC enforcement.
**API Tokens (PATs)**
- Migration 015: `api_tokens` table (PG + SQLite) with SHA-256 hash, prefix, JSON permissions, expiry
- Token store interface + PG/SQLite implementations (Create, GetByHash, ListForUser, Revoke, CleanExpired, UpdateLastUsed)
- `POST /api/v1/auth/tokens` — create token (returns plaintext once), permissions validated as subset of user's
- `GET /api/v1/auth/tokens` — list my tokens; `DELETE /api/v1/auth/tokens/:id` — revoke
- `POST /api/v1/admin/tokens` — create token for any user (audit logged as `admin.token.create`)
- Auth middleware: `Bearer arm_pat_...` tokens validated alongside JWTs, user active check, fire-and-forget `last_used_at` update
- Permission scoping: PAT permissions used directly at request time (git model — retained until revoked)
- `auth.HashToken()` shared SHA-256 utility (replaces local `hashToken()` in auth.go)
- Settings UI: API Tokens tab with create form, permission checkboxes, copy-once display, revoke button
- Admin UI: "PAT" button on user rows creates tokens for any user
- `BootstrapPAT`: `ARMATURE_BOOTSTRAP_PAT=true` env var creates admin PAT at startup, writes to `/tmp/armature-admin-pat.txt`
- E2E smoke test: reads bootstrap PAT before falling back to login flow
**Extension-Declared User Permissions**
- Dynamic permission registry: `RegisterExtensionPermissions()` / `UnregisterExtensionPermissions()` with RWMutex
- `AllPermissionsWithExtensions()` returns kernel + extension permissions; `AllPermissionsGrouped()` for admin UI
- `user_permissions` manifest field: extensions declare user-facing permissions
- `gate_permission` manifest field: ext_api.go checks user permission before calling `on_request`
- `req["permissions"]` in Starlark request dict: user's effective permissions included for inline checks
- `permissions.check(user_id, perm)` Starlark module: read-only permission check, always available (no sandbox gate)
- Group UI: permissions grouped by source (Platform / package name) with section headings
- Boot-time scan: `RegisterAllExtensionUserPermissions()` populates registry from active packages
- Uninstall cleanup: `UnregisterExtensionPermissions()` called on package delete
**Tests:** 10 new tests (7 handler + 3 auth registry)
---
## v0.7.6 — Code Hygiene + Test Coverage
**Critical Fixes**