Skip to content

Commit

Permalink
[shopsys] Upgrade some composer dependencies (#3688)
Browse files Browse the repository at this point in the history
  • Loading branch information
henzigo authored Dec 23, 2024
2 parents f8abb2e + b2ac233 commit c8c0bbd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
"php": "^8.3",
"elasticsearch/elasticsearch": "^7.6.1",
"hybridauth/hybridauth": "^3.11",
"lcobucci/jwt": "^4.1.5",
"lcobucci/clock": "^3.3",
"lcobucci/jwt": "^5.4",
"overblog/graphql-bundle": "1.3.2",
"overblog/graphiql-bundle": "^0.3",
"overblog/dataloader-bundle": "^0.6.0",
"overblog/graphiql-bundle": "^1.0",
"overblog/dataloader-bundle": "^1.1",
"shopsys/form-types-bundle": "16.0.x-dev",
"shopsys/framework": "16.0.x-dev",
"shopsys/migrations": "16.0.x-dev",
Expand Down
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ parameters:
treatPhpDocTypesAsCertain: false

ignoreErrors:
-
# in fact, anything can be passed to the load function, it just has a bad annotation
message: '#^Parameter \#1 \$key of method Overblog\\DataLoader\\DataLoaderInterface::load\(\) expects string#'
path: %currentWorkingDirectory%/*

includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
Expand Down
19 changes: 8 additions & 11 deletions src/Model/Token/TokenFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,12 @@ public function createAccessTokenAsString(
string $deviceId,
?Administrator $administrator = null,
): string {
$tokenBuilder = $this->getTokenBuilderWithExpiration(static::ACCESS_TOKEN_EXPIRATION);
$tokenBuilder->withClaim(FrontendApiUser::CLAIM_DEVICE_ID, $deviceId);
$tokenBuilder->withClaim(
FrontendApiUser::CLAIM_ADMINISTRATOR_UUID,
$administrator?->getUuid(),
);
$tokenBuilder = $this->getTokenBuilderWithExpiration(static::ACCESS_TOKEN_EXPIRATION)
->withClaim(FrontendApiUser::CLAIM_DEVICE_ID, $deviceId)
->withClaim(FrontendApiUser::CLAIM_ADMINISTRATOR_UUID, $administrator?->getUuid());

foreach (TokenCustomerUserTransformer::transform($customerUser) as $key => $value) {
$tokenBuilder->withClaim($key, $value);
$tokenBuilder = $tokenBuilder->withClaim($key, $value);
}

$jwtConfiguration = $this->jwtConfigurationProvider->getConfiguration();
Expand All @@ -87,10 +84,10 @@ public function generateRefreshTokenByCustomerUserAndSecretChainAndDeviceId(
string $secretChain,
string $deviceId,
): UnencryptedToken {
$tokenBuilder = $this->getTokenBuilderWithExpiration(static::REFRESH_TOKEN_EXPIRATION);
$tokenBuilder->withClaim(FrontendApiUser::CLAIM_UUID, $customerUser->getUuid());
$tokenBuilder->withClaim(FrontendApiUser::CLAIM_SECRET_CHAIN, $secretChain);
$tokenBuilder->withClaim(FrontendApiUser::CLAIM_DEVICE_ID, $deviceId);
$tokenBuilder = $this->getTokenBuilderWithExpiration(static::REFRESH_TOKEN_EXPIRATION)
->withClaim(FrontendApiUser::CLAIM_UUID, $customerUser->getUuid())
->withClaim(FrontendApiUser::CLAIM_SECRET_CHAIN, $secretChain)
->withClaim(FrontendApiUser::CLAIM_DEVICE_ID, $deviceId);

$jwtConfiguration = $this->jwtConfigurationProvider->getConfiguration();

Expand Down
15 changes: 9 additions & 6 deletions tests/Unit/Model/Token/TokenFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Lcobucci\JWT\Encoding\JoseEncoder;
use Lcobucci\JWT\Signer\Key\InMemory;
use Lcobucci\JWT\Token\Builder;
use Lcobucci\JWT\Token\Plain;
use Lcobucci\JWT\UnencryptedToken;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig;
Expand Down Expand Up @@ -54,10 +54,13 @@ public function testTokenValidation(
* @param string|null $issuedBy
* @param \Lcobucci\JWT\Signer\Key\InMemory|null $privateKey
* @param \DateTimeImmutable|null $expiresAt
* @return \Lcobucci\JWT\Token\Plain
* @return \Lcobucci\JWT\UnencryptedToken
*/
protected function createToken(?string $issuedBy, ?InMemory $privateKey, ?DateTimeImmutable $expiresAt): Plain
{
protected function createToken(
?string $issuedBy,
?InMemory $privateKey,
?DateTimeImmutable $expiresAt,
): UnencryptedToken {
$builder = (new Builder(new JoseEncoder(), ChainedFormatter::default()))
->issuedBy('http://webserver:8080')
->permittedFor('http://webserver:8080')
Expand All @@ -73,11 +76,11 @@ protected function createToken(?string $issuedBy, ?InMemory $privateKey, ?DateTi
}

if ($issuedBy !== null) {
$builder->issuedBy($issuedBy);
$builder = $builder->issuedBy($issuedBy);
}

if ($expiresAt !== null) {
$builder->expiresAt($expiresAt);
$builder = $builder->expiresAt($expiresAt);
}

return $builder->getToken($signer, $privateKey);
Expand Down

0 comments on commit c8c0bbd

Please sign in to comment.