Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed May 30, 2024
1 parent f43ceca commit 152f22d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/Http/Middleware/AuthenticateApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Closure;
use Illuminate\Http\Request;

const REQUEST_MAX_AGE_THRESHOLD_SECONDS = 60; // 60 seconds
const REQUEST_MAX_AGE_THRESHOLD_SECONDS = 600; // servers can be out of sync against NTP servers by various minutes so give some buffer .
const VALIDATE_SIGNATURE = true; // For testing purposes, we can disable signature validation.

class AuthenticateApiKey
Expand Down Expand Up @@ -73,6 +73,8 @@ public function handle(Request $request, Closure $next)
$timestamp = $timestampMs / 1000;
$currentTimestamp = now()->timestamp;
$requestAge = abs($currentTimestamp - $timestamp);
\Log::info('local timestamp: '.now()->timestamp.' - server timestamp: '.$timestampMs);
\Log::info('Request Age: '.$requestAge);
if ($requestAge > REQUEST_MAX_AGE_THRESHOLD_SECONDS) {
return response()->json([
'status' => 'error',
Expand Down

0 comments on commit 152f22d

Please sign in to comment.