Skip to content

Commit

Permalink
refactor: Use constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Feb 10, 2021
1 parent 35d9ac7 commit be2cf3b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Service/KeyLoader/ApiGwKeyLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
*/
final class ApiGwKeyLoader implements KeyLoaderInterface
{
private const API_GW_ACCEPTANCE = 'https://api.acceptance.tech.ec.europa.eu/federation/oauth/token/.well-known/jwks.json';

private const API_GW_INTRA = 'https://intrapi.tech.ec.europa.eu/federation/oauth/token/.well-known/jwks.json';

private const API_GW_PRODUCTION = 'https://api.tech.ec.europa.eu/federation/oauth/token/.well-known/jwks.json';

private const LOCAL_FAILSAFE_PATH = __DIR__ . '/../../Resources/keys';

private array $configuration;

private array $environment;
Expand All @@ -30,28 +38,28 @@ final class ApiGwKeyLoader implements KeyLoaderInterface
private static array $mapping = [
[
'env' => 'production',
KeyLoaderInterface::TYPE_PUBLIC => 'https://api.tech.ec.europa.eu/federation/oauth/token/.well-known/jwks.json',
KeyLoaderInterface::TYPE_PUBLIC => self::API_GW_PRODUCTION,
KeyLoaderInterface::TYPE_PRIVATE => '',
'failsafe' => [
KeyLoaderInterface::TYPE_PUBLIC => __DIR__ . '/../../Resources/keys/production/jwks.json',
KeyLoaderInterface::TYPE_PUBLIC => self::LOCAL_FAILSAFE_PATH . '/production/jwks.json',
KeyLoaderInterface::TYPE_PRIVATE => '',
],
],
[
'env' => 'intra',
KeyLoaderInterface::TYPE_PUBLIC => 'https://intrapi.tech.ec.europa.eu/federation/oauth/token/.well-known/jwks.json',
KeyLoaderInterface::TYPE_PUBLIC => self::API_GW_INTRA,
KeyLoaderInterface::TYPE_PRIVATE => '',
'failsafe' => [
KeyLoaderInterface::TYPE_PUBLIC => __DIR__ . '/../../Resources/keys/intra/jwks.json',
KeyLoaderInterface::TYPE_PUBLIC => self::LOCAL_FAILSAFE_PATH . '/intra/jwks.json',
KeyLoaderInterface::TYPE_PRIVATE => '',
],
],
[
'env' => 'acceptance',
KeyLoaderInterface::TYPE_PUBLIC => 'https://api.acceptance.tech.ec.europa.eu/federation/oauth/token/.well-known/jwks.json',
KeyLoaderInterface::TYPE_PUBLIC => self::API_GW_ACCEPTANCE,
KeyLoaderInterface::TYPE_PRIVATE => '',
'failsafe' => [
KeyLoaderInterface::TYPE_PUBLIC => __DIR__ . '/../../Resources/keys/acceptance/jwks.json',
KeyLoaderInterface::TYPE_PUBLIC => self::LOCAL_FAILSAFE_PATH . '/acceptance/jwks.json',
KeyLoaderInterface::TYPE_PRIVATE => '',
],
],
Expand Down

0 comments on commit be2cf3b

Please sign in to comment.