fix(security): enforce ownership on GET date-override (IDOR)
getOverride leaked any doctor's override to any authenticated user; add the owner-or-admin check (matching the update/delete endpoints) + regression test.
This commit is contained in:
@@ -237,13 +237,17 @@ class AppointmentSettingsController extends BaseController
|
||||
}
|
||||
|
||||
#[Route('/api/v1/appointment-settings/date-override/{uuid}', methods: ['GET'])]
|
||||
public function getOverride(string $uuid): JsonResponse
|
||||
public function getOverride(string $uuid, #[CurrentUser] User $user): JsonResponse
|
||||
{
|
||||
$override = $this->overrideRepo->findByUuid($uuid);
|
||||
if ($override === null) {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'Override یافت نشد', 404);
|
||||
}
|
||||
|
||||
if ($override->getDoctor()->getUser()->getId() !== $user->getId() && !$user->hasRole('ROLE_ADMIN')) {
|
||||
return $this->error(ErrorCodes::ERR_AUTH_006, 'دسترسی ممنوع', 403);
|
||||
}
|
||||
|
||||
return $this->success(['data' => $override->toArray()]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user