Skip to content

Commit 5598a94

Browse files
Added leeway usage to README
1 parent e191fd0 commit 5598a94

9 files changed

+39
-23
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ matrix:
66
- php: 7.0
77
- php: 7.1
88
- php: 7.2
9-
- php: 7.3
109
- php: nightly
1110
- php: hhvm-3.6
1211
sudo: required
@@ -36,6 +35,8 @@ matrix:
3635
- php: hhvm-3.12
3736
- php: hhvm-3.15
3837
- php: hhvm-nightly
38+
- php: 7.3
39+
- php: 7.4
3940

4041
before_script:
4142
- travis_retry composer self-update

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ All Notable changes to `oauth2-apple` will be documented in this file
1818
### Security
1919
- Nothing
2020

21+
## 0.2.3 - 2021-01-05
22+
23+
### Added
24+
- Using guzzle http instead of file_get_contents [#14](https://github.com/patrickbussmann/oauth2-apple/pull/14)/[#17](https://github.com/patrickbussmann/oauth2-apple/pull/17) (thanks to [jmalinens](https://github.com/jmalinens) and [williamxsp](https://github.com/williamxsp))
25+
- README no scope instruction [#15](https://github.com/patrickbussmann/oauth2-apple/pull/15) (thanks to [NgSekLong](https://github.com/NgSekLong))
26+
- README leeway usage [#18](https://github.com/patrickbussmann/oauth2-apple/issues/18) (thanks to [lukequinnell](https://github.com/lukequinnell))
27+
28+
### Fixed
29+
- Fixed getting first and last name issues [#13](https://github.com/patrickbussmann/oauth2-apple/pull/13) (thanks to [bogdandovgopol](https://github.com/bogdandovgopol))
30+
2131
## 0.2.1 - 2020-02-13
2232

2333
### Added

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ Usage is the same as The League's OAuth client, using `\League\OAuth2\Client\Pro
3232
### Authorization Code Flow
3333

3434
```php
35+
// $leeway is needed for clock skew
36+
Firebase\JWT\JWT::$leeway = 60;
37+
3538
$provider = new League\OAuth2\Client\Provider\Apple([
3639
'clientId' => '{apple-client-id}',
3740
'teamId' => '{apple-team-id}', // 1A234BFK46 https://developer.apple.com/account/#/membership/ (Team ID)
3841
'keyFileId' => '{apple-key-file-id}', // 1ABC6523AA https://developer.apple.com/account/resources/authkeys/list (Key ID)
39-
'keyFilePath' => '{apple-key-file-path}', // __DIR__ . '/AuthKey_1ABC6523AA.p8' -> Download key above
42+
'keyFilePath' => '{apple-key-file-path}', // __DIR__ . '/AuthKey_1ABC6523AA.p8' -> Download key above
4043
'redirectUri' => 'https://example.com/callback-url',
4144
]);
4245

@@ -133,7 +136,7 @@ Please see [CONTRIBUTING](https://github.com/patrickbussmann/oauth2-apple/blob/m
133136

134137
- [All Contributors](https://github.com/patrickbussmann/oauth2-apple/contributors)
135138

136-
Template for this repository was the [LinkedIn](https://github.com/thephpleague/oauth2-linkedin).
139+
Template for this repository was the [LinkedIn](https://github.com/thephpleague/oauth2-linkedin).
137140

138141
## License
139142

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
"league/oauth2-client": "^2.0",
2323
"ext-json": "*",
2424
"firebase/php-jwt": "^5.2",
25-
"lcobucci/jwt": "^3.3"
25+
"lcobucci/jwt": "~3.3.3"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "~4.0",
29-
"mockery/mockery": "~0.9",
28+
"phpunit/phpunit": "^4.8|^7.5",
29+
"mockery/mockery": "~1.3.3",
3030
"squizlabs/php_codesniffer": "~2.0",
3131
"ext-json": "*"
3232
},

phpunit.xml

-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
>
1312
<logging>
1413
<log type="coverage-html"
1514
target="./build/coverage/html"
16-
charset="UTF-8"
17-
highlight="false"
1815
lowUpperBound="35"
1916
highLowerBound="70"/>
2017
<log type="coverage-clover"

src/Provider/Apple.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function __construct(array $options = [], array $collaborators = [])
7676
*/
7777
protected function createAccessToken(array $response, AbstractGrant $grant)
7878
{
79-
return new AppleAccessToken($response, $this->getHttpClient());
79+
return new AppleAccessToken($this->getHttpClient(), $response);
8080
}
8181

8282
/**
@@ -210,12 +210,13 @@ public function getAccessToken($grant, array $options = [])
210210
{
211211
$signer = new Sha256();
212212
$time = new \DateTimeImmutable();
213+
$expiresAt = $time->modify('+1 Hour');
213214

214215
$token = (new Builder())
215216
->issuedBy($this->teamId)
216217
->permittedFor('https://appleid.apple.com')
217-
->issuedAt($time)
218-
->expiresAt((clone $time)->modify('+1 Hour'))
218+
->issuedAt($time->getTimestamp())
219+
->expiresAt($expiresAt->getTimestamp())
219220
->relatedTo($this->clientId)
220221
->withHeader('alg', 'ES256')
221222
->withHeader('kid', $this->keyFileId)

src/Token/AppleAccessToken.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ class AppleAccessToken extends AccessToken
3232
/**
3333
* Constructs an access token.
3434
*
35+
* @param ClientInterface $httpClient the http client to use
3536
* @param array $options An array of options returned by the service provider
3637
* in the access token request. The `access_token` option is required.
3738
* @throws InvalidArgumentException if `access_token` is not provided in `$options`.
3839
*
3940
* @throws \Exception
4041
*/
41-
public function __construct(array $options = [], $httpClient)
42+
public function __construct($httpClient, array $options = [])
4243
{
4344
$this->httpClient = $httpClient;
4445

test/src/Provider/AppleTest.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
use League\OAuth2\Client\Provider\Exception\AppleAccessDeniedException;
1414
use League\OAuth2\Client\Token\AccessToken;
1515
use League\OAuth2\Client\Tool\QueryBuilderTrait;
16+
use PHPUnit\Framework\TestCase;
1617
use Mockery as m;
1718

18-
class AppleTest extends \PHPUnit_Framework_TestCase
19+
class AppleTest extends TestCase
1920
{
2021
use QueryBuilderTrait;
2122

@@ -143,12 +144,13 @@ public function testGetAccessToken()
143144
]);
144145
$provider = m::mock($provider);
145146

146-
$time = new \DateTimeImmutable();
147+
$time = new \DateTimeImmutable();
148+
$expiresAt = $time->modify('+1 Hour');
147149
$token = (new Builder())
148150
->issuedBy('test-team-id')
149151
->permittedFor('https://appleid.apple.com')
150-
->issuedAt($time)
151-
->expiresAt((clone $time)->modify('+1 Hour'))
152+
->issuedAt($time->getTimestamp())
153+
->expiresAt($expiresAt->getTimestamp())
152154
->relatedTo('test-client')
153155
->withClaim('sub', 'test')
154156
->withHeader('alg', 'RS256')
@@ -213,10 +215,11 @@ public function testNotImplementedGetResourceOwnerDetailsUrl()
213215
$this->provider->getResourceOwnerDetailsUrl(new AccessToken(['access_token' => 'hello']));
214216
}
215217

218+
/**
219+
* @expectedException \League\OAuth2\Client\Provider\Exception\AppleAccessDeniedException
220+
*/
216221
public function testCheckResponse()
217222
{
218-
$this->setExpectedException(AppleAccessDeniedException::class, 'invalid_client', 400);
219-
220223
$class = new \ReflectionClass($this->provider);
221224
$method = $class->getMethod('checkResponse');
222225
$method->setAccessible(true);

test/src/Token/AppleAccessTokenTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@ public function testCreatingAccessToken()
3535
->once()
3636
->andReturn(['examplekey']);
3737

38-
$accessToken = new AppleAccessToken([
38+
$accessToken = new AppleAccessToken($this->getClient(1), [
3939
'access_token' => 'access_token',
4040
'token_type' => 'Bearer',
4141
'expires_in' => 3600,
4242
'refresh_token' => 'abc.0.def',
4343
'id_token' => 'something'
44-
], $this->getClient(1));
44+
]);
4545
$this->assertEquals('something', $accessToken->getIdToken());
4646
$this->assertEquals('123.abc.123', $accessToken->getResourceOwnerId());
4747
$this->assertEquals('access_token', $accessToken->getToken());
4848
}
4949

5050
public function testCreatingRefreshToken()
5151
{
52-
$refreshToken = new AppleAccessToken([
52+
$refreshToken = new AppleAccessToken($this->getClient(0), [
5353
'access_token' => 'access_token',
5454
'token_type' => 'Bearer',
5555
'expires_in' => 3600
56-
], $this->getClient(0));
56+
]);
5757
$this->assertEquals('access_token', $refreshToken->getToken());
5858
}
5959

0 commit comments

Comments
 (0)