Skip to content

Commit

Permalink
Code style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KorvinSzanto committed Jun 4, 2024
1 parent 63ba789 commit e0e8847
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/Api/Jwt/SignedWithOidc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

class SignedWithOidc implements SignedWith, LoggerAwareInterface
{

use LoggerAwareTrait;

public function __construct(
protected ExpensiveCache $cache,
protected Client $client,
Expand Down Expand Up @@ -65,6 +65,11 @@ public function assert(Token $token): void
(new JwtSignedWith($signer, InMemory::plainText($key)))->assert($token);
}

public function getLoggerChannel(): string
{
return Channels::CHANNEL_API;
}

protected function getKey(string $issuer, string $kid): ?string
{
$jwks = $this->getJwkUri($issuer);
Expand Down Expand Up @@ -93,6 +98,7 @@ protected function getKey(string $issuer, string $kid): ?string
}
} catch (\Throwable $e) {
$this->logger?->warning('Unable to load OIDC JWKs: ' . $e->getMessage());

return null;
}

Expand All @@ -103,6 +109,7 @@ protected function getKey(string $issuer, string $kid): ?string

if ($e === '' || $n === '') {
$this->logger?->warning('Unable to load OIDC JWK, invalid base64');

return null;
}

Expand All @@ -113,6 +120,7 @@ protected function getKey(string $issuer, string $kid): ?string
]);
} catch (\Throwable $e) {
$this->logger?->warning('Unable to load OIDC key: ' . $e->getMessage());

return null;
}
}
Expand Down Expand Up @@ -155,11 +163,6 @@ private function getJwkUri(string $issuer): ?string
return $data['jwks_uri'] ?? null;
}

public function getLoggerChannel(): string
{
return Channels::CHANNEL_API;
}

private function cacheResponse(ItemInterface $cacheItem, string $json, ResponseInterface $response): void
{
preg_match('/max-age=(\d+)/', $response->getHeader('Cache-Control')[0] ?? '', $matches);
Expand All @@ -171,4 +174,4 @@ private function cacheResponse(ItemInterface $cacheItem, string $json, ResponseI
$cacheItem->save();
}
}
}
}
4 changes: 2 additions & 2 deletions src/Api/UserControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function checkGenericAccess(string $configKey): void
return;
case self::ACCESSOPTION_MARKET:
$this->validateMarketToken();

return;
case self::ACCESSOPTION_ROOT:
$user = $this->getRequestUser();
Expand Down Expand Up @@ -202,7 +203,6 @@ public function checkLocaleAccess(string $configKey): array
}

return $this->getApprovedLocales();

case self::ACCESSOPTION_MARKET:
throw new AccessDeniedException();
case self::ACCESSOPTION_ROOT:
Expand Down Expand Up @@ -412,7 +412,7 @@ private function getConfiguredAccessLevel(string $configKey): string
/**
* @throws AccessDeniedException
*/
public function validateMarketToken(): void
private function validateMarketToken(): void
{
// Extract the JWT from the request if one exists
try {
Expand Down

0 comments on commit e0e8847

Please sign in to comment.