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:
@@ -72,7 +72,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/crowd-lists");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists");
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertCount(3, $response->json('data'));
|
||||
@@ -86,7 +86,7 @@ class CrowdListTest extends TestCase
|
||||
{
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->postJson("/api/v1/events/{$this->event->id}/crowd-lists", [
|
||||
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists", [
|
||||
'crowd_type_id' => $this->crowdType->id,
|
||||
'name' => 'VIP Gastenlijst',
|
||||
'type' => 'internal',
|
||||
@@ -116,7 +116,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->postJson("/api/v1/events/{$this->event->id}/crowd-lists", [
|
||||
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists", [
|
||||
'crowd_type_id' => $this->crowdType->id,
|
||||
'name' => 'Catering Medewerkers',
|
||||
'type' => 'external',
|
||||
@@ -132,7 +132,7 @@ class CrowdListTest extends TestCase
|
||||
{
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->postJson("/api/v1/events/{$this->event->id}/crowd-lists", [
|
||||
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists", [
|
||||
'crowd_type_id' => $this->crowdType->id,
|
||||
'name' => 'Test List',
|
||||
'type' => 'invalid_type',
|
||||
@@ -154,7 +154,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}", [
|
||||
'name' => 'Nieuwe Naam',
|
||||
'auto_approve' => true,
|
||||
'max_persons' => 25,
|
||||
@@ -175,7 +175,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}");
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}");
|
||||
|
||||
$response->assertNoContent();
|
||||
$this->assertDatabaseMissing('crowd_lists', ['id' => $crowdList->id]);
|
||||
@@ -196,7 +196,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->postJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
'person_id' => $person->id,
|
||||
]);
|
||||
|
||||
@@ -227,7 +227,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->postJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
'person_id' => $person->id,
|
||||
]);
|
||||
|
||||
@@ -258,7 +258,7 @@ class CrowdListTest extends TestCase
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
// Try to add 3rd person
|
||||
$response = $this->postJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
'person_id' => $persons->last()->id,
|
||||
]);
|
||||
|
||||
@@ -283,7 +283,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
// Add all 5 persons — no limit
|
||||
foreach ($persons as $person) {
|
||||
$response = $this->postJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
'person_id' => $person->id,
|
||||
]);
|
||||
$response->assertOk();
|
||||
@@ -306,7 +306,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->postJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons", [
|
||||
'person_id' => $person->id,
|
||||
]);
|
||||
|
||||
@@ -336,7 +336,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons/{$person->id}");
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons/{$person->id}");
|
||||
|
||||
$response->assertNoContent();
|
||||
|
||||
@@ -370,7 +370,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/crowd-lists");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists");
|
||||
|
||||
$response->assertOk();
|
||||
$listData = collect($response->json('data'))->firstWhere('id', $crowdList->id);
|
||||
@@ -400,7 +400,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons");
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertCount(3, $response->json('data'));
|
||||
@@ -433,7 +433,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons");
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJsonStructure([
|
||||
@@ -454,7 +454,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->outsider);
|
||||
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}/persons");
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
@@ -465,14 +465,14 @@ class CrowdListTest extends TestCase
|
||||
{
|
||||
Sanctum::actingAs($this->outsider);
|
||||
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/crowd-lists");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists");
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_unauthenticated_cannot_access_crowd_lists(): void
|
||||
{
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/crowd-lists");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists");
|
||||
|
||||
$response->assertUnauthorized();
|
||||
}
|
||||
@@ -490,7 +490,7 @@ class CrowdListTest extends TestCase
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
// Try to update a list from event A via event B's URL
|
||||
$response = $this->putJson("/api/v1/events/{$eventB->id}/crowd-lists/{$crowdList->id}", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$eventB->id}/crowd-lists/{$crowdList->id}", [
|
||||
'name' => 'Hacked',
|
||||
]);
|
||||
|
||||
@@ -517,7 +517,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$this->deleteJson("/api/v1/events/{$this->event->id}/crowd-lists/{$crowdList->id}")
|
||||
$this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists/{$crowdList->id}")
|
||||
->assertNoContent();
|
||||
|
||||
// Pivot removed (cascade)
|
||||
@@ -553,7 +553,7 @@ class CrowdListTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/crowd-lists");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/crowd-lists");
|
||||
|
||||
$response->assertOk();
|
||||
$listData = collect($response->json('data'))->firstWhere('id', $crowdList->id);
|
||||
|
||||
Reference in New Issue
Block a user