Skip to content

Commit d5048c7

Browse files
authored
Allow lcobucci/jwt ^5.0 (#44)
1 parent 74818d3 commit d5048c7

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"ext-json": "*",
2323
"league/oauth2-client": "^2.0",
2424
"firebase/php-jwt": "^5.2 || ^6.0",
25-
"lcobucci/jwt": "^3.4 || ^4.0"
25+
"lcobucci/jwt": "^3.4 || ^4.0 || ^5.0"
2626
},
2727
"require-dev": {
2828
"phpunit/phpunit": "^5.7 || ^6.0 || ^9.3",

test/src/KeyDumpSigner.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace League\OAuth2\Client\Test;
4+
5+
use Lcobucci\JWT\Signer;
6+
use Lcobucci\JWT\Signer\Key;
7+
8+
final class KeyDumpSigner implements Signer
9+
{
10+
public function algorithmId(): string
11+
{
12+
return 'keydump';
13+
}
14+
15+
public function sign(string $payload, Key $key): string
16+
{
17+
return $key->contents();
18+
}
19+
20+
public function verify(string $expected, string $payload, Key $key): bool
21+
{
22+
return $expected === $key->contents();
23+
}
24+
}

test/src/Provider/AppleTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
use GuzzleHttp\Psr7\Response;
77
use Lcobucci\JWT\Configuration;
88
use Lcobucci\JWT\Signer\Key;
9+
use Lcobucci\JWT\Signer\Hmac\Sha256;
910
use League\OAuth2\Client\Provider\Apple;
1011
use League\OAuth2\Client\Provider\AppleResourceOwner;
12+
use League\OAuth2\Client\Test\KeyDumpSigner;
1113
use League\OAuth2\Client\Token\AccessToken;
1214
use League\OAuth2\Client\Token\AppleAccessToken;
1315
use League\OAuth2\Client\Tool\QueryBuilderTrait;
@@ -131,7 +133,10 @@ public function testGetAccessToken()
131133
$provider = m::mock($provider);
132134

133135

134-
$configuration = Configuration::forUnsecuredSigner();
136+
$configuration = Configuration::forSymmetricSigner(
137+
new KeyDumpSigner(),
138+
Key\InMemory::plainText('private')
139+
);
135140

136141
$time = new \DateTimeImmutable();
137142
$expiresAt = $time->modify('+1 Hour');

test/src/Provider/TestApple.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace League\OAuth2\Client\Test\Provider;
44

55
use Lcobucci\JWT\Configuration;
6+
use Lcobucci\JWT\Signer\Key\InMemory;
67
use League\OAuth2\Client\Provider\Apple;
8+
use League\OAuth2\Client\Test\KeyDumpSigner;
79

810
/**
911
* Class TestApple
@@ -17,7 +19,10 @@ class TestApple extends Apple
1719
*/
1820
public function getConfiguration()
1921
{
20-
return Configuration::forUnsecuredSigner();
22+
return Configuration::forSymmetricSigner(
23+
new KeyDumpSigner(),
24+
InMemory::plainText('private')
25+
);
2126
}
2227

2328
/**

0 commit comments

Comments
 (0)