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:
@@ -2191,8 +2191,9 @@ class subusersRoute
|
|||||||
'edit_subusers' => 'List chauffeur permission templates while editing chauffeur grants.',
|
'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 () {
|
$this->post('/subusers', function () {
|
||||||
ScopeMiddleware::requireScope(Scope::SUBUSER_WRITE, '/subusers');
|
|
||||||
$this->registerPublicSubuser();
|
$this->registerPublicSubuser();
|
||||||
});
|
});
|
||||||
$this->get('/subusers/setup', function () {
|
$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.',
|
'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
|
// 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 () {
|
$this->post('/subusers/me', function () {
|
||||||
ScopeMiddleware::requireScope(Scope::SUBUSER_WRITE, '/subusers/me');
|
|
||||||
$this->registerPublicSubuser();
|
$this->registerPublicSubuser();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user