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

@@ -54,7 +54,7 @@ class FestivalEventTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->festival->id}/time-slots", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->festival->id}/time-slots", [
'name' => 'Opbouw Vrijdag',
'person_type' => 'CREW',
'date' => '2026-07-10',
@@ -81,7 +81,7 @@ class FestivalEventTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->festival->id}/sections", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->festival->id}/sections", [
'name' => 'Terreinploeg',
'sort_order' => 1,
'type' => 'standard',
@@ -112,7 +112,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->festival->id}/sections/{$section->id}/shifts", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->festival->id}/sections/{$section->id}/shifts", [
'time_slot_id' => $timeSlot->id,
'title' => 'Terreinmedewerker',
'slots_total' => 8,
@@ -151,7 +151,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->getJson("/api/v1/events/{$this->subEvent->id}/sections");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/sections");
$response->assertOk();
@@ -181,7 +181,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->getJson("/api/v1/events/{$this->subEvent->id}/time-slots");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/time-slots");
$response->assertOk();
@@ -216,7 +216,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
// Query persons on festival level — should only return festival-level persons
$response = $this->getJson("/api/v1/events/{$this->festival->id}/persons");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->festival->id}/persons");
$response->assertOk();
@@ -231,7 +231,7 @@ class FestivalEventTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->subEvent->id}/sections", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/sections", [
'name' => 'EHBO',
'type' => 'cross_event',
]);
@@ -258,7 +258,7 @@ class FestivalEventTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->festival->id}/sections", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->festival->id}/sections", [
'name' => 'Security',
'type' => 'cross_event',
]);
@@ -283,7 +283,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$flatEvent->id}/sections", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$flatEvent->id}/sections", [
'name' => 'EHBO',
'type' => 'cross_event',
]);
@@ -298,13 +298,13 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
// Create cross_event via sub-event A → redirects to parent
$this->postJson("/api/v1/events/{$this->subEvent->id}/sections", [
$this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/sections", [
'name' => 'Verkeersregelaars',
'type' => 'cross_event',
])->assertCreated();
// Should appear in sub-event B's section list
$response = $this->getJson("/api/v1/events/{$subEventB->id}/sections");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$subEventB->id}/sections");
$response->assertOk();
$sectionNames = collect($response->json('data'))->pluck('name')->all();
@@ -315,7 +315,7 @@ class FestivalEventTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->subEvent->id}/sections", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/sections", [
'name' => 'Bar Schirmbar',
'type' => 'standard',
]);
@@ -403,7 +403,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->getJson("/api/v1/events/{$this->subEvent->id}/time-slots?include_parent=true");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/time-slots?include_parent=true");
$response->assertOk();
@@ -439,7 +439,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
// Even with include_parent, festival parent should only return its own TS
$response = $this->getJson("/api/v1/events/{$this->festival->id}/time-slots?include_parent=true");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->festival->id}/time-slots?include_parent=true");
$response->assertOk();
@@ -461,7 +461,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->subEvent->id}/sections/{$section->id}/shifts", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/sections/{$section->id}/shifts", [
'time_slot_id' => $festivalTimeSlot->id,
'title' => 'Opbouwshift',
'slots_total' => 4,
@@ -494,7 +494,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->subEvent->id}/sections/{$section->id}/shifts", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/sections/{$section->id}/shifts", [
'time_slot_id' => $otherTimeSlot->id,
'title' => 'Illegale shift',
'slots_total' => 1,
@@ -518,7 +518,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
// include_parent has no effect on flat events
$response = $this->getJson("/api/v1/events/{$flatEvent->id}/time-slots?include_parent=true");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$flatEvent->id}/time-slots?include_parent=true");
$response->assertOk();
@@ -559,7 +559,7 @@ class FestivalEventTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
// Assign person to the shift
$this->postJson("/api/v1/events/{$this->subEvent->id}/sections/{$section->id}/shifts/{$shift->id}/assign", [
$this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/sections/{$section->id}/shifts/{$shift->id}/assign", [
'person_id' => $person->id,
])->assertCreated();
@@ -576,7 +576,7 @@ class FestivalEventTest extends TestCase
]);
// Assigning the same person to same time_slot should fail
$response = $this->postJson("/api/v1/events/{$this->subEvent->id}/sections/{$section2->id}/shifts/{$shift2->id}/assign", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/sections/{$section2->id}/shifts/{$shift2->id}/assign", [
'person_id' => $person->id,
]);