diff --git a/Operation/ExchangeToken.php b/Operation/ExchangeToken.php index ee17670..a390b3d 100644 --- a/Operation/ExchangeToken.php +++ b/Operation/ExchangeToken.php @@ -2,6 +2,7 @@ namespace Ivoz\Api\Operation; +use ApiPlatform\Core\EventListener\EventPriorities; use ApiPlatform\Core\Exception\ResourceClassNotFoundException; use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTCreatedEvent; use Lexik\Bundle\JWTAuthenticationBundle\Events; @@ -92,6 +93,12 @@ public function execute(string $inputToken, string $username): string $tokenChain[] = $parentAdminTokenPayload['onBehalfOf']; } $tokenChain[] = $parentAdminTokenPayload['iden']; + + if (isset($parentAdminTokenPayload['onBehalfOfIds'])) { + $payload['onBehalfOfIds'] = $parentAdminTokenPayload['onBehalfOfIds']; + } + $payload['onBehalfOfIds'][] = $targetAdmin->getId(); + $payload['onBehalfOf'] = implode(' > ', $tokenChain); $payload['iden'] = (string) $targetAdmin; @@ -100,7 +107,8 @@ public function execute(string $inputToken, string $username): string $this->eventDispatcher->addListener( Events::JWT_CREATED, - $payloadModifier + $payloadModifier, + EventPriorities::PRE_VALIDATE ); $newToken = $this->jwtTokenManager->create($targetAdmin); diff --git a/phpstan.neon b/phpstan.neon index 412b80d..8fc4e2c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,3 +4,63 @@ parameters: - vendor ignoreErrors: - '#Parameter \#2 \$hydrationMode of method Doctrine\\ORM\\Query::iterate\(\) expects [0-9\|]+string\|null, 101 given#' + + - + message: "#^Deprecated in PHP 8\\.1\\: Required parameter \\$resourceMetadataFactory follows optional parameter \\$nameConverter\\.$#" + count: 1 + path: Doctrine/Orm/Filter/BooleanFilter.php + + - + message: "#^Deprecated in PHP 8\\.1\\: Required parameter \\$resourceMetadataFactory follows optional parameter \\$nameConverter\\.$#" + count: 1 + path: Doctrine/Orm/Filter/DateFilter.php + + - + message: "#^Deprecated in PHP 8\\.1\\: Required parameter \\$resourceMetadataFactory follows optional parameter \\$nameConverter\\.$#" + count: 1 + path: Doctrine/Orm/Filter/NotEqualFilter.php + + - + message: "#^Deprecated in PHP 8\\.1\\: Required parameter \\$resourceMetadataFactory follows optional parameter \\$nameConverter\\.$#" + count: 1 + path: Doctrine/Orm/Filter/NumericFilter.php + + - + message: "#^Deprecated in PHP 8\\.0\\: Required parameter \\$resourceMetadataFactory follows optional parameter \\$requestStack\\.$#" + count: 1 + path: Doctrine/Orm/Filter/OrderFilter.php + + - + message: "#^Deprecated in PHP 8\\.1\\: Required parameter \\$orderParameterName follows optional parameter \\$requestStack\\.$#" + count: 1 + path: Doctrine/Orm/Filter/OrderFilter.php + + - + message: "#^Deprecated in PHP 8\\.1\\: Required parameter \\$resourceMetadataFactory follows optional parameter \\$properties\\.$#" + count: 1 + path: Doctrine/Orm/Filter/RangeFilter.php + + - + message: "#^Deprecated in PHP 8\\.0\\: Required parameter \\$resourceMetadataFactory follows optional parameter \\$requestStack\\.$#" + count: 1 + path: Doctrine/Orm/Filter/SearchFilter.php + + - + message: "#^Deprecated in PHP 8\\.1\\: Required parameter \\$iriConverter follows optional parameter \\$requestStack\\.$#" + count: 1 + path: Doctrine/Orm/Filter/SearchFilter.php + + - + message: "#^Deprecated in PHP 8\\.0\\: Required parameter \\$propertyMetadataFactory follows optional parameter \\$requestStack\\.$#" + count: 1 + path: Doctrine/Orm/Filter/SearchFilterExact.php + + - + message: "#^Deprecated in PHP 8\\.0\\: Required parameter \\$resourceMetadataFactory follows optional parameter \\$requestStack\\.$#" + count: 1 + path: Doctrine/Orm/Filter/SearchFilterExact.php + + - + message: "#^Deprecated in PHP 8\\.1\\: Required parameter \\$iriConverter follows optional parameter \\$requestStack\\.$#" + count: 1 + path: Doctrine/Orm/Filter/SearchFilterExact.php