Log when an API key is blocked due to IP restrictions

This commit is contained in:
DaneEveritt 2022-06-18 12:04:51 -04:00
parent 0be96cfd26
commit 6ffe5730da
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 8 additions and 0 deletions

View file

@ -6,6 +6,7 @@ use Closure;
use IPTools\IP;
use IPTools\Range;
use Illuminate\Http\Request;
use Pterodactyl\Facades\Activity;
use Laravel\Sanctum\TransientToken;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@ -39,6 +40,12 @@ class AuthenticateIPAccess
}
}
Activity::event('auth:ip-blocked')
->actor($request->user())
->subject($request->user(), $token)
->property('identifier', $token->identifier)
->log();
throw new AccessDeniedHttpException('This IP address (' . $request->ip() . ') does not have permission to access the API using these credentials.');
}
}