Skip to content

Commit 231ef17

Browse files
committed
Merge branch '10.x'
# Conflicts: # CHANGELOG.md
2 parents d239c98 + ba1996c commit 231ef17

File tree

7 files changed

+98
-15
lines changed

7 files changed

+98
-15
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ jobs:
1313
strategy:
1414
fail-fast: true
1515
matrix:
16-
php: [7.3, 7.4, 8.0, 8.1]
17-
laravel: [^8.0]
16+
php: [7.3, 7.4, '8.0', 8.1]
17+
laravel: [8, 9]
18+
exclude:
19+
- php: 7.3
20+
laravel: 9
21+
- php: 7.4
22+
laravel: 9
1823

1924
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
2025

@@ -32,7 +37,7 @@ jobs:
3237

3338
- name: Install dependencies
3439
run: |
35-
composer require "illuminate/contracts=${{ matrix.laravel }}" --no-update
40+
composer require "illuminate/contracts=^${{ matrix.laravel }}" --no-update
3641
composer update --prefer-dist --no-interaction --no-progress
3742
3843
- name: Execute tests

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# Release Notes
22

3-
## [Unreleased](https://github.com/laravel/passport/compare/v10.2.1...master)
3+
## [Unreleased](https://github.com/laravel/passport/compare/v10.3.0...master)
4+
5+
6+
## [v10.3.0 (2022-01-12)](https://github.com/laravel/passport/compare/v10.2.2...v10.3.0)
7+
8+
### Changed
9+
- Laravel 9 Support ([#1516](https://github.com/laravel/passport/pull/1516))
10+
11+
12+
## [v10.2.2 (2021-12-07)](https://github.com/laravel/passport/compare/v10.2.1...v10.2.2)
13+
14+
### Fixed
15+
- Fix jsonSerialize PHP 8.1 issue ([#1512](https://github.com/laravel/passport/pull/1512))
416

517

618
## [v10.2.1 (2021-12-07)](https://github.com/laravel/passport/compare/v10.2.0...v10.2.1)

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"php": "^7.3|^8.0",
1818
"ext-json": "*",
1919
"firebase/php-jwt": "^5.0",
20-
"illuminate/auth": "^8.2",
21-
"illuminate/console": "^8.2",
22-
"illuminate/container": "^8.2",
23-
"illuminate/contracts": "^8.2",
24-
"illuminate/cookie": "^8.2",
25-
"illuminate/database": "^8.2",
26-
"illuminate/encryption": "^8.2",
27-
"illuminate/http": "^8.2",
28-
"illuminate/support": "^8.2",
20+
"illuminate/auth": "^8.2|^9.0",
21+
"illuminate/console": "^8.2|^9.0",
22+
"illuminate/container": "^8.2|^9.0",
23+
"illuminate/contracts": "^8.2|^9.0",
24+
"illuminate/cookie": "^8.2|^9.0",
25+
"illuminate/database": "^8.2|^9.0",
26+
"illuminate/encryption": "^8.2|^9.0",
27+
"illuminate/http": "^8.2|^9.0",
28+
"illuminate/support": "^8.2|^9.0",
2929
"lcobucci/jwt": "^3.4|^4.0",
3030
"league/oauth2-server": "^8.2",
3131
"nyholm/psr7": "^1.3",
@@ -34,7 +34,7 @@
3434
},
3535
"require-dev": {
3636
"mockery/mockery": "^1.0",
37-
"orchestra/testbench": "^6.0",
37+
"orchestra/testbench": "^6.0|^7.0",
3838
"phpunit/phpunit": "^9.3"
3939
},
4040
"autoload": {

src/Bridge/Scope.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function __construct($name)
2525
*
2626
* @return mixed
2727
*/
28+
#[\ReturnTypeWillChange]
2829
public function jsonSerialize()
2930
{
3031
return $this->getIdentifier();

src/Passport.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ class Passport
181181
*/
182182
public static $withInheritedScopes = false;
183183

184+
/**
185+
* The authorization server response type.
186+
*
187+
* @var \League\OAuth2\Server\ResponseTypes\ResponseTypeInterface|null
188+
*/
189+
public static $authorizationServerResponseType;
190+
184191
/**
185192
* Enable the implicit grant type.
186193
*

src/PassportServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ public function makeAuthorizationServer()
258258
$this->app->make(Bridge\AccessTokenRepository::class),
259259
$this->app->make(Bridge\ScopeRepository::class),
260260
$this->makeCryptKey('private'),
261-
app('encrypter')->getKey()
261+
app('encrypter')->getKey(),
262+
Passport::$authorizationServerResponseType
262263
);
263264
}
264265

tests/Feature/AccessTokenControllerTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Laravel\Passport\ClientRepository;
1111
use Laravel\Passport\Database\Factories\ClientFactory;
1212
use Laravel\Passport\HasApiTokens;
13+
use Laravel\Passport\Passport;
1314
use Laravel\Passport\Token;
1415
use Laravel\Passport\TokenRepository;
1516
use Lcobucci\JWT\Configuration;
@@ -270,9 +271,65 @@ public function testGettingAccessTokenWithPasswordGrantWithInvalidClientSecret()
270271

271272
$this->assertSame(0, Token::count());
272273
}
274+
275+
public function testGettingCustomResponseType()
276+
{
277+
$this->withoutExceptionHandling();
278+
Passport::$authorizationServerResponseType = new IdTokenResponse('foo_bar_open_id_token');
279+
280+
$user = new User();
281+
$user->email = '[email protected]';
282+
$user->password = $this->app->make(Hasher::class)->make('foobar123');
283+
$user->save();
284+
285+
/** @var Client $client */
286+
$client = ClientFactory::new()->asClientCredentials()->create(['user_id' => $user->id]);
287+
288+
$response = $this->post(
289+
'/oauth/token',
290+
[
291+
'grant_type' => 'client_credentials',
292+
'client_id' => $client->id,
293+
'client_secret' => $client->secret,
294+
]
295+
);
296+
297+
$response->assertOk();
298+
299+
$decodedResponse = $response->decodeResponseJson()->json();
300+
301+
$this->assertArrayHasKey('id_token', $decodedResponse);
302+
$this->assertSame('foo_bar_open_id_token', $decodedResponse['id_token']);
303+
}
273304
}
274305

275306
class User extends \Illuminate\Foundation\Auth\User
276307
{
277308
use HasApiTokens;
278309
}
310+
311+
class IdTokenResponse extends \League\OAuth2\Server\ResponseTypes\BearerTokenResponse
312+
{
313+
/**
314+
* @var string Id token.
315+
*/
316+
protected $idToken;
317+
318+
/**
319+
* @param string $idToken
320+
*/
321+
public function __construct($idToken)
322+
{
323+
$this->idToken = $idToken;
324+
}
325+
326+
/**
327+
* @inheritdoc
328+
*/
329+
protected function getExtraParams(\League\OAuth2\Server\Entities\AccessTokenEntityInterface $accessToken)
330+
{
331+
return [
332+
'id_token' => $this->idToken,
333+
];
334+
}
335+
}

0 commit comments

Comments
 (0)