Skip to content

Commit 355adbd

Browse files
committed
Update ApiAuthMiddleware.php
1 parent 51226a8 commit 355adbd

1 file changed

Lines changed: 1 addition & 29 deletions

File tree

app/Http/Middleware/ApiAuthMiddleware.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,57 +16,29 @@ public function handle($request, Closure $next)
1616
$authHeader = $request->header('Authorization');
1717
$isBasicAuth = $authHeader && str_starts_with($authHeader, 'Basic ');
1818

19-
Log::debug('ApiAuthMiddleware: incoming request', [
20-
'path' => $request->path(),
21-
'method' => $request->method(),
22-
'has_api_key' => !empty($apiKey),
23-
'is_basic_auth' => (bool) $isBasicAuth,
24-
]);
25-
2619
if (!$apiKey && !$isBasicAuth) {
27-
Log::debug('ApiAuthMiddleware: authentication missing');
2820
return response()->json(['error' => 'Authentication required. Provide API key or Basic auth'], 401);
2921
}
3022

3123
if ($isBasicAuth) {
32-
Log::debug('ApiAuthMiddleware: delegating to BasicAuth');
3324
return parent::handle($request, $next);
3425
}
3526

3627
if ($apiKey) {
3728
$application = Application::query()->where('key', '=', $apiKey)->first();
3829

3930
if (!$application) {
40-
Log::debug('ApiAuthMiddleware: invalid api key', [
41-
'api_key_prefix' => substr($apiKey, 0, 6),
42-
'path' => $request->path(),
43-
]);
31+
4432
return response()->json(['error' => 'Invalid API key'], 401);
4533
}
4634

47-
Log::debug('ApiAuthMiddleware: application resolved', [
48-
'application_id' => $application->id,
49-
'tenant_user_id' => $application->tenant_user_id,
50-
'is_active' => (bool) $application->is_active,
51-
'is_trashed' => $application->trashed(),
52-
'rules' => (array) $application->rules,
53-
]);
5435

5536
if ($application->trashed() || !$application->is_active) {
56-
Log::debug('ApiAuthMiddleware: application unavailable', [
57-
'application_id' => $application->id,
58-
]);
5937
return response()->json(['error' => 'Application is unavailable'], 403);
6038
}
6139

6240
$canAccess = $this->canAccessRequestedVersion($request->path(), (array) $application->rules);
6341

64-
Log::debug('ApiAuthMiddleware: version access decision', [
65-
'application_id' => $application->id,
66-
'path' => $request->path(),
67-
'can_access' => $canAccess,
68-
]);
69-
7042
if (!$canAccess) {
7143
return response()->json(['error' => 'Application is not allowed to access this API version'], 403);
7244
}

0 commit comments

Comments
 (0)