Skip to content

Commit 1f92a7d

Browse files
committed
Authenticate that the request is coming from someone that should even know about the server
1 parent 5717a70 commit 1f92a7d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ public function handle(Request $request, Closure $next)
4242
throw new NotFoundHttpException(trans('exceptions.api.resource_not_found'));
4343
}
4444

45+
// At the very least, ensure that the user trying to make this request is the
46+
// server owner, a subuser, or a root admin. We'll leave it up to the controllers
47+
// to authenticate more detailed permissions if needed.
48+
if ($request->user()->id !== $server->owner_id && ! $request->user()->root_admin) {
49+
// Check for subuser status.
50+
if (! $server->subusers->contains('user_id', $request->user()->id)) {
51+
throw new NotFoundHttpException(trans('exceptions.api.resource_not_found'));
52+
}
53+
}
54+
4555
if ($server->suspended) {
4656
throw new AccessDeniedHttpException('Cannot access a server that is marked as being suspended.');
4757
}

0 commit comments

Comments
 (0)