security: A01-13 — nest all event routes under organisation prefix

Move all authenticated organiser-facing event sub-resource routes from
/events/{event}/... to /organisations/{organisation}/events/{event}/...
to enforce multi-tenancy at the routing layer.

Changes:
- Routes: restructured api.php to nest all event sub-resources under
  the existing organisation prefix group
- Controllers: added Organisation parameter and VerifiesOrganisationEvent
  trait to all 12 affected controllers (sections, time-slots, shifts,
  persons, crowd-lists, locations, shift-assignments, registration-fields,
  availabilities, field-values, section-preferences, stats)
- Tests: updated all 20 feature test files with new route paths
- Frontend: updated 8 API composables and 20 Vue components/pages
- API.md: updated documentation to reflect new route structure

Portal routes, public routes (volunteer-register), and invitation routes
remain unchanged as they operate without organisation context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-14 08:16:36 +02:00
parent 51e5dd6fcb
commit 7932e53daf
64 changed files with 726 additions and 568 deletions

View File

@@ -65,7 +65,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->getJson("/api/v1/events/{$this->event->id}/registration-fields");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields");
$response->assertOk();
$this->assertCount(3, $response->json('data'));
@@ -78,7 +78,7 @@ class RegistrationFormFieldTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields", [
'label' => 'Shirtmaat',
'field_type' => 'select',
'options' => ['XS', 'S', 'M', 'L', 'XL'],
@@ -98,7 +98,7 @@ class RegistrationFormFieldTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields", [
'label' => 'Shirtmaat',
'field_type' => 'select',
]);
@@ -111,7 +111,7 @@ class RegistrationFormFieldTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields", [
'label' => 'Naam',
'field_type' => 'text',
'options' => ['A', 'B'],
@@ -125,7 +125,7 @@ class RegistrationFormFieldTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields", [
'label' => 'Vaardigheden',
'field_type' => 'tag_picker',
'tag_category' => 'Vaardigheid',
@@ -139,7 +139,7 @@ class RegistrationFormFieldTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields", [
'label' => 'Naam',
'field_type' => 'text',
'tag_category' => 'Vaardigheid',
@@ -159,7 +159,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields", [
'label' => 'Shirtmaat',
'field_type' => 'text',
]);
@@ -180,7 +180,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$otherEvent->id}/registration-fields", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$otherEvent->id}/registration-fields", [
'label' => 'Shirtmaat',
'field_type' => 'text',
]);
@@ -199,7 +199,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->putJson("/api/v1/events/{$this->event->id}/registration-fields/{$field->id}", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields/{$field->id}", [
'label' => 'New Label',
]);
@@ -217,7 +217,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->putJson("/api/v1/events/{$this->event->id}/registration-fields/{$field->id}", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields/{$field->id}", [
'field_type' => 'select',
]);
@@ -237,7 +237,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->deleteJson("/api/v1/events/{$this->event->id}/registration-fields/{$field->id}");
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields/{$field->id}");
$response->assertNoContent();
$this->assertDatabaseMissing('registration_form_fields', [
@@ -262,7 +262,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields/reorder", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields/reorder", [
'ids' => [$fieldC->id, $fieldA->id, $fieldB->id],
]);
@@ -293,7 +293,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields/import-from-event", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields/import-from-event", [
'source_event_id' => $sourceEvent->id,
]);
@@ -315,7 +315,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields/import-from-event", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields/import-from-event", [
'source_event_id' => $otherEvent->id,
]);
@@ -331,7 +331,7 @@ class RegistrationFormFieldTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/registration-fields/from-template", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields/from-template", [
'template_id' => $template->id,
]);
@@ -349,14 +349,14 @@ class RegistrationFormFieldTest extends TestCase
{
Sanctum::actingAs($this->outsider);
$response = $this->getJson("/api/v1/events/{$this->event->id}/registration-fields");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields");
$response->assertForbidden();
}
public function test_unauthenticated_returns_401(): void
{
$response = $this->getJson("/api/v1/events/{$this->event->id}/registration-fields");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields");
$response->assertUnauthorized();
}