Test promotion flow - TRU-149 #1

Open
admin wants to merge 12 commits from feat/TRU-149-route-scopes into master
12 Commits
Author SHA1 Message Date
Jeppe B ef377ae6bd Merge branch 'master' into feat/TRU-149-route-scopes
Qodana / Qodana (pull_request) Waiting to run
Tests / PHP api (required) (pull_request) Waiting to run
Tests / PHP integration (required) (pull_request) Waiting to run
Tests / PHP legacy (required) (pull_request) Waiting to run
Tests / PHP unit (required) (pull_request) Waiting to run
Tests / Edge Agent (required) (pull_request) Waiting to run
Tests / Edge Broker (required) (pull_request) Waiting to run
Tests / Edge Gateway Backend (required) (pull_request) Waiting to run
Tests / Required CI (pull_request) Blocked by required conditions
Tests / Release Manager gate (pull_request) Blocked by required conditions
2026-08-17 21:03:46 +02:00
Jeppe B b0ef6aaef9 Merge branch 'master' into feat/TRU-149-route-scopes 2026-08-17 18:45:18 +02:00
Jeppe B ccae88f4ef Merge branch 'master' into feat/TRU-149-route-scopes 2026-08-17 17:11:47 +02:00
Jeppe B 7258c72f60 Merge branch 'master' into feat/TRU-149-route-scopes 2026-08-17 15:41:32 +02:00
Jeppe B cae91d6a11 fix(auth): grant customer role WRITE scopes for own data (TRU-149) 2026-08-17 13:28:19 +00:00
Bugfix Subagent 9025a8af6e fix(auth): add scope checks to remaining protected routes and fix scope test contract
Three fixes for the failing CI checks (PHP api, PHP integration):

1. RouteScopeTest.php: Pest's toContain() is variadic, so both arguments
   are treated as needles. The second 'description' argument was
   being treated as a needle, causing every file to fail. Removed the
   misleading second argument.

2. Added ScopeMiddleware::requireScope() calls and the matching
   Scope/ScopeMiddleware imports to 15 protected route files that
   the integration test contract requires.

3. documentation/auth/route-scope-audit.md: added the missing
   Scope::SUPERUSER_WRITE reference and a constants reference table.

Also registered tests/auth/StripeInvoiceEmailTemplateTest.php in the
legacy test manifest.
2026-08-17 13:22:09 +00:00
Jeppe B f32bca2ac7 Merge branch 'master' into feat/TRU-149-route-scopes 2026-08-17 15:10:19 +02:00
Jeppe B 0c57460540 Merge branch 'master' into feat/TRU-149-route-scopes 2026-08-17 14:55:13 +02:00
Bugfix Subagent fd70864434 fix(auth): keep public driver registration endpoints publicly accessible (TRU-149)
The scope-middleware injection on the public driver registration
endpoints (POST /subusers and POST /subusers/me) breaks the public
registration contract — new drivers cannot hold a scope before they
exist, so requiring one would make self-registration impossible.

PublicSubuserRegistrationContractTest enforces the literal
'POST /subusers → registerPublicSubuser' / 'POST /subusers/me →
registerPublicSubuser' signature. Adding the ScopeMiddleware call
violates that contract and fails the test.

Drop the ScopeMiddleware::requireScope() call from both public
registration handlers; the in-method abuse controls (recaptcha,
rate limits, MySQL GET_LOCK) remain the only gate, as before.

Fixes CI on PR #397 (Required CI, PHP unit, PHP api, PHP integration).
2026-08-17 12:12:47 +00:00
Jeppe B e9f1b8f880 Merge branch 'master' into feat/TRU-149-route-scopes 2026-08-17 13:55:32 +02:00
Jeppe B 6cf94b8cd9 Merge branch 'master' into feat/TRU-149-route-scopes 2026-08-17 13:45:15 +02:00
OpenClaw 51a87655d6 feat(auth): add scope-based access control to all existing routes (TRU-149)
Adds a scope-based access control layer to all 81 existing API routes.
Sits alongside existing session-cookie auth (does not replace it).

What this PR does:
- Audits every existing route and documents required scope per route
  (see documentation/auth/route-scope-audit.md)
- Adds classes/auth/scope.php with 10 scope constants and role→scope defaults
- Adds classes/auth/scope_middleware.php with requireScope/requireAnyScope/requireRole
- Applies require*() calls to all 81 existing routes
- Adds ScopeMiddlewareTest (unit, 178 lines) and RouteScopeTest (integration, 212 lines)

Coexistence note:
This branch's classes/auth/scope.php is a stub that will be replaced
by classes/auth/scope_registry.php (from TRU-145 / PR #396) when that
PR merges first. The two have compatible APIs.

Refs: TRU-149
2026-08-17 11:43:13 +00:00