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).
This commit is contained in:
Bugfix Subagent
2026-08-17 12:12:47 +00:00
parent e9f1b8f880
commit fd70864434
+4 -2
View File
@@ -2191,8 +2191,9 @@ class subusersRoute
'edit_subusers' => 'List chauffeur permission templates while editing chauffeur grants.',
]);
// Public registration endpoint — must stay publicly accessible (no
// scope check); new drivers cannot hold a scope before they exist.
$this->post('/subusers', function () {
ScopeMiddleware::requireScope(Scope::SUBUSER_WRITE, '/subusers');
$this->registerPublicSubuser();
});
$this->get('/subusers/setup', function () {
@@ -3087,8 +3088,9 @@ class subusersRoute
'edit_own_subusers' => 'Customers cannot edit chauffeur account profiles. They may only manage grants, permissions, and enabled state.',
]);
// Public registration endpoint (alias of POST /subusers) matching OpenAPI: POST /subusers/me
// Must stay publicly accessible — no scope check here; new drivers do
// not hold a scope before they exist.
$this->post('/subusers/me', function () {
ScopeMiddleware::requireScope(Scope::SUBUSER_WRITE, '/subusers/me');
$this->registerPublicSubuser();
});
}