Skip to content

Commit

Permalink
Allow lcobucci/jwt ^5.0 (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanvelzen committed May 17, 2024
1 parent 74818d3 commit d5048c7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ext-json": "*",
"league/oauth2-client": "^2.0",
"firebase/php-jwt": "^5.2 || ^6.0",
"lcobucci/jwt": "^3.4 || ^4.0"
"lcobucci/jwt": "^3.4 || ^4.0 || ^5.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.0 || ^9.3",
Expand Down
24 changes: 24 additions & 0 deletions test/src/KeyDumpSigner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace League\OAuth2\Client\Test;

use Lcobucci\JWT\Signer;
use Lcobucci\JWT\Signer\Key;

final class KeyDumpSigner implements Signer
{
public function algorithmId(): string
{
return 'keydump';
}

public function sign(string $payload, Key $key): string
{
return $key->contents();
}

public function verify(string $expected, string $payload, Key $key): bool
{
return $expected === $key->contents();
}
}
7 changes: 6 additions & 1 deletion test/src/Provider/AppleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
use GuzzleHttp\Psr7\Response;
use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Signer\Key;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use League\OAuth2\Client\Provider\Apple;
use League\OAuth2\Client\Provider\AppleResourceOwner;
use League\OAuth2\Client\Test\KeyDumpSigner;
use League\OAuth2\Client\Token\AccessToken;
use League\OAuth2\Client\Token\AppleAccessToken;
use League\OAuth2\Client\Tool\QueryBuilderTrait;
Expand Down Expand Up @@ -131,7 +133,10 @@ public function testGetAccessToken()
$provider = m::mock($provider);


$configuration = Configuration::forUnsecuredSigner();
$configuration = Configuration::forSymmetricSigner(
new KeyDumpSigner(),
Key\InMemory::plainText('private')
);

$time = new \DateTimeImmutable();
$expiresAt = $time->modify('+1 Hour');
Expand Down
7 changes: 6 additions & 1 deletion test/src/Provider/TestApple.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace League\OAuth2\Client\Test\Provider;

use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Signer\Key\InMemory;
use League\OAuth2\Client\Provider\Apple;
use League\OAuth2\Client\Test\KeyDumpSigner;

/**
* Class TestApple
Expand All @@ -17,7 +19,10 @@ class TestApple extends Apple
*/
public function getConfiguration()
{
return Configuration::forUnsecuredSigner();
return Configuration::forSymmetricSigner(
new KeyDumpSigner(),
InMemory::plainText('private')
);
}

/**
Expand Down

0 comments on commit d5048c7

Please sign in to comment.