Skip to content

Commit 4451c88

Browse files
committed
Only enforce org check for v2 API
Make organisation access enforcement conditional on API version by defaulting $canAccessOrganisation to true and only calling canAccessOrganisation() for paths starting with 'v2/'. This avoids applying organisation-level rules to non-v2 endpoints and prevents unnecessary 403 responses for older API versions.
1 parent 418cf42 commit 4451c88

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

app/Http/Middleware/ApiAuthMiddleware.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ public function handle($request, Closure $next)
4444
return response()->json(['error' => 'Application is not allowed to access this API version'], 403);
4545
}
4646

47-
$canAccessOrganisation = $this->canAccessOrganisation($request->path(), (array) $application->rules);
47+
$canAccessOrganisation = true;
48+
if (strpos($request->path(), 'v2/') === 0) {
49+
$canAccessOrganisation = $this->canAccessOrganisation($request->path(), (array) $application->rules);
50+
}
4851

4952
if (!$canAccessOrganisation) {
5053
return response()->json(['error' => 'Application is not allowed to access this organisation'], 403);

0 commit comments

Comments
 (0)