Skip to content

Commit

Permalink
feat: reject requests with default seat contact
Browse files Browse the repository at this point in the history
  • Loading branch information
Crypta-Eve committed Jan 23, 2025
1 parent 53f92a0 commit 3f6ea77
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Eseye.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Seat\Eseye\Containers\EsiResponse;
use Seat\Eseye\Exceptions\EsiScopeAccessDeniedException;
use Seat\Eseye\Exceptions\InvalidAuthenticationException;
use Seat\Eseye\Exceptions\InvalidConfigurationException;
use Seat\Eseye\Exceptions\InvalidContainerDataException;
use Seat\Eseye\Exceptions\UriDataMissingException;
use Seat\Eseye\Fetchers\FetcherInterface;
Expand All @@ -48,7 +49,7 @@ class Eseye
/**
* The Eseye Version.
*/
const VERSION = '3.0.0';
const VERSION = '3.2.0';

/**
* @var \Seat\Eseye\Containers\EsiAuthentication|null
Expand Down Expand Up @@ -311,6 +312,7 @@ public function setVersion(string $version): Eseye
* @throws \Seat\Eseye\Exceptions\EsiScopeAccessDeniedException
* @throws \Seat\Eseye\Exceptions\RequestFailedException
* @throws \Seat\Eseye\Exceptions\InvalidAuthenticationException
* @throws \Seat\Eseye\Exceptions\InvalidConfigurationException
* @throws \Seat\Eseye\Exceptions\InvalidContainerDataException
* @throws \Seat\Eseye\Exceptions\UriDataMissingException
* @throws \Psr\SimpleCache\InvalidArgumentException
Expand All @@ -320,6 +322,15 @@ public function invoke(string $method, string $endpoint, array $uri_data = []):
// Build the URI from the parts we have.
$uri = $this->buildDataUri($endpoint, $uri_data);

// Make sure our user agent does not contain the default seat contact email
if ( str_contains($this->getConfiguration()->http_user_agent, "seatadmin@localhost.local") ){

// Log the lack of config.
$this->getConfiguration()->getLogger()->error('Access denied to ' . $uri . ' due to default user agent configuration.');

throw new InvalidConfigurationException('Access denied to ' . $uri . ' due to default user agent configuration.');
}

// Check the Access Requirement
if (! $this->getAccessChecker()->can(
$method, $endpoint, $this->getFetcher()->getAuthenticationScopes())
Expand Down

0 comments on commit 3f6ea77

Please sign in to comment.