Skip to content

Commit 1ab39f2

Browse files
committed
Merge branch '11.x'
2 parents 4ade47f + eb78ec6 commit 1ab39f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+655
-229
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
.gitignore export-ignore
1515
.styleci.yml export-ignore
1616
CHANGELOG.md export-ignore
17+
phpstan.neon.dist export-ignore
1718
phpunit.xml.dist export-ignore
1819
UPGRADE.md

.github/ISSUE_TEMPLATE/1_Bug_report.md

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Bug Report
2+
description: "Report a general library issue."
3+
body:
4+
- type: markdown
5+
attributes:
6+
value: "Before submitting your report, [please ensure your Laravel version is still supported](https://laravel.com/docs/releases#support-policy)."
7+
- type: input
8+
attributes:
9+
label: Passport Version
10+
description: Provide the Passport version that you are using.
11+
placeholder: 10.0.1
12+
validations:
13+
required: true
14+
- type: input
15+
attributes:
16+
label: Laravel Version
17+
description: Provide the Laravel version that you are using.
18+
placeholder: 10.4.1
19+
validations:
20+
required: true
21+
- type: input
22+
attributes:
23+
label: PHP Version
24+
description: Provide the PHP version that you are using.
25+
placeholder: 8.1.4
26+
validations:
27+
required: true
28+
- type: input
29+
attributes:
30+
label: Database Driver & Version
31+
description: If applicable, provide the database driver and version you are using.
32+
placeholder: "MySQL 8.0.31 for macOS 13.0 on arm64 (Homebrew)"
33+
validations:
34+
required: false
35+
- type: textarea
36+
attributes:
37+
label: Description
38+
description: Provide a detailed description of the issue you are facing.
39+
validations:
40+
required: true
41+
- type: textarea
42+
attributes:
43+
label: Steps To Reproduce
44+
description: Provide detailed steps to reproduce your issue. If necessary, please provide a GitHub repository to demonstrate your issue using `laravel new bug-report --github="--public"`.
45+
validations:
46+
required: true
47+

.github/workflows/static-analysis.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- '*.x'
8+
pull_request:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
tests:
15+
runs-on: ubuntu-22.04
16+
17+
strategy:
18+
fail-fast: true
19+
20+
name: Static Analysis
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: 8.2
30+
tools: composer:v2
31+
coverage: none
32+
33+
- name: Install dependencies
34+
uses: nick-fields/retry@v2
35+
with:
36+
timeout_minutes: 5
37+
max_attempts: 5
38+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
39+
40+
- name: Execute type checking
41+
run: vendor/bin/phpstan

.github/workflows/tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ jobs:
1616
strategy:
1717
fail-fast: true
1818
matrix:
19-
php: ['8.0', 8.1, 8.2]
19+
php: ['8.0', 8.1, 8.2, 8.3]
2020
laravel: [9, 10]
2121
exclude:
2222
- php: '8.0'
2323
laravel: 10
24+
- php: 8.3
25+
laravel: 9
2426

2527
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
2628

2729
steps:
2830
- name: Checkout code
29-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
3032

3133
- name: Setup PHP
3234
uses: shivammathur/setup-php@v2

CHANGELOG.md

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

3-
## [Unreleased](https://github.com/laravel/passport/compare/v11.8.0...master)
3+
## [Unreleased](https://github.com/laravel/passport/compare/v11.10.0...master)
4+
5+
## [v11.10.0](https://github.com/laravel/passport/compare/v11.9.2...v11.10.0) - 2023-11-02
6+
7+
- [11.x] Named static methods for middleware by [@michaelnabil230](https://github.com/michaelnabil230) in https://github.com/laravel/passport/pull/1695
8+
- Simplify Conditional Statement by [@michaelnabil230](https://github.com/michaelnabil230) in https://github.com/laravel/passport/pull/1696
9+
10+
## [v11.9.2](https://github.com/laravel/passport/compare/v11.9.1...v11.9.2) - 2023-10-16
11+
12+
- Add return to revokeRefreshTokensByAccessTokenId method by [@aminkhoshzahmat](https://github.com/aminkhoshzahmat) in https://github.com/laravel/passport/pull/1693
13+
14+
## [v11.9.1](https://github.com/laravel/passport/compare/v11.9.0...v11.9.1) - 2023-09-01
15+
16+
- [11.x] Allow scope repository to be constructed without parameters by [@axlon](https://github.com/axlon) in https://github.com/laravel/passport/pull/1686
17+
18+
## [v11.9.0](https://github.com/laravel/passport/compare/v11.8.8...v11.9.0) - 2023-08-29
19+
20+
- [11.x] Add the ability to limit scopes by client by [@axlon](https://github.com/axlon) in https://github.com/laravel/passport/pull/1682
21+
- [11.x] Add support for inherited scopes when limiting scopes on clients by [@axlon](https://github.com/axlon) in https://github.com/laravel/passport/pull/1683
22+
23+
## [v11.8.8](https://github.com/laravel/passport/compare/v11.8.7...v11.8.8) - 2023-07-07
24+
25+
- Add generics to client factory by [@axlon](https://github.com/axlon) in https://github.com/laravel/passport/pull/1669
26+
- Update composer.json by [@Smoggert](https://github.com/Smoggert) in https://github.com/laravel/passport/pull/1674
27+
- Update composer.json by [@drhoussem](https://github.com/drhoussem) in https://github.com/laravel/passport/pull/1677
28+
29+
## [v11.8.7](https://github.com/laravel/passport/compare/v11.8.6...v11.8.7) - 2023-04-28
30+
31+
- Revert "[11.x] Add Provider Guard to ClientRepository for Personal Access Clients" by @driesvints in https://github.com/laravel/passport/pull/1658
32+
33+
## [v11.8.6](https://github.com/laravel/passport/compare/v11.8.5...v11.8.6) - 2023-04-24
34+
35+
- Add Provider Guard to ClientRepository for Personal Access Clients by @michaelnabil230 in https://github.com/laravel/passport/pull/1655
36+
37+
## [v11.8.5](https://github.com/laravel/passport/compare/v11.8.4...v11.8.5) - 2023-04-04
38+
39+
- Allow `lcobucci/jwt` v5 and cleaned up version constraints by @GrahamCampbell in https://github.com/laravel/passport/pull/1649
40+
- Pass user identifier through to finalize scopes in personal access grant by @GrahamCampbell in https://github.com/laravel/passport/pull/1650
41+
42+
## [v11.8.4](https://github.com/laravel/passport/compare/v11.8.3...v11.8.4) - 2023-03-18
43+
44+
- Removed deprecated `dates` property from `RefreshToken` model by @siarheipashkevich in https://github.com/laravel/passport/pull/1645
45+
- Removed deprecated `dates` property from `AuthCode` model by @siarheipashkevich in https://github.com/laravel/passport/pull/1644
46+
- Fix doc block types by @hafezdivandari in https://github.com/laravel/passport/pull/1647
47+
48+
## [v11.8.3](https://github.com/laravel/passport/compare/v11.8.2...v11.8.3) - 2023-03-01
49+
50+
- Allow overriding the `AccessToken` class by @hafezdivandari in https://github.com/laravel/passport/pull/1638
51+
- Make `$userId` nullable in `ClientRepository->createPersonalAccessClient` by @bram-pkg in https://github.com/laravel/passport/pull/1642
52+
53+
## [v11.8.2](https://github.com/laravel/passport/compare/v11.8.1...v11.8.2) - 2023-02-20
54+
55+
- Re-apply "Added AuthenticationException to extend the behaviour of Laravel's default exception handler" by @driesvints in https://github.com/laravel/passport/commit/67c3e336af163f6eba5dbca8e5db46275ff0e433
56+
57+
## [v11.8.1](https://github.com/laravel/passport/compare/v11.8.0...v11.8.1) - 2023-02-20
58+
59+
- Revert "Move AuthenticationException into the scope of Laravel Passport" by @driesvints in https://github.com/laravel/passport/commit/db543b0cc13ed3f56f1bffda04707fbe2a8c7ab5
460

561
## [v11.8.0](https://github.com/laravel/passport/compare/v11.7.0...v11.8.0) - 2023-02-17
662

composer.json

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"require": {
1717
"php": "^8.0",
1818
"ext-json": "*",
19-
"firebase/php-jwt": "^6.3.1",
19+
"firebase/php-jwt": "^6.4",
2020
"illuminate/auth": "^9.0|^10.0",
2121
"illuminate/console": "^9.0|^10.0",
2222
"illuminate/container": "^9.0|^10.0",
@@ -26,15 +26,16 @@
2626
"illuminate/encryption": "^9.0|^10.0",
2727
"illuminate/http": "^9.0|^10.0",
2828
"illuminate/support": "^9.0|^10.0",
29-
"lcobucci/jwt": "^3.4|^4.0",
30-
"league/oauth2-server": "^8.2",
31-
"nyholm/psr7": "^1.3",
29+
"lcobucci/jwt": "^4.3|^5.0",
30+
"league/oauth2-server": "^8.5.3",
31+
"nyholm/psr7": "^1.5",
3232
"phpseclib/phpseclib": "^2.0|^3.0",
33-
"symfony/psr-http-message-bridge": "^2.0"
33+
"symfony/psr-http-message-bridge": "^2.1"
3434
},
3535
"require-dev": {
3636
"mockery/mockery": "^1.0",
37-
"orchestra/testbench": "^7.0|^8.0",
37+
"orchestra/testbench": "^7.31|^8.11",
38+
"phpstan/phpstan": "^1.10",
3839
"phpunit/phpunit": "^9.3"
3940
},
4041
"autoload": {
@@ -45,7 +46,9 @@
4546
},
4647
"autoload-dev": {
4748
"psr-4": {
48-
"Laravel\\Passport\\Tests\\": "tests/"
49+
"Laravel\\Passport\\Tests\\": "tests/",
50+
"Workbench\\App\\": "workbench/app/",
51+
"Workbench\\Database\\Factories\\": "workbench/database/factories/"
4952
}
5053
},
5154
"extra": {
@@ -61,6 +64,10 @@
6164
"config": {
6265
"sort-packages": true
6366
},
67+
"scripts": {
68+
"post-autoload-dump": "@prepare",
69+
"prepare": "@php vendor/bin/testbench package:discover --ansi"
70+
},
6471
"minimum-stability": "dev",
6572
"prefer-stable": true
6673
}

database/factories/ClientFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Laravel\Passport\Client;
88
use Laravel\Passport\Passport;
99

10+
/**
11+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Laravel\Passport\Client>
12+
*/
1013
class ClientFactory extends Factory
1114
{
1215
/**

phpstan.neon.dist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
paths:
3+
- config
4+
- database
5+
- routes
6+
- src
7+
8+
level: 0
9+
10+
ignoreErrors:
11+
- "#Unsafe usage of new static\\(\\)#"

src/AuthCode.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,7 @@ class AuthCode extends Model
3434
*/
3535
protected $casts = [
3636
'revoked' => 'bool',
37-
];
38-
39-
/**
40-
* The attributes that should be mutated to dates.
41-
*
42-
* @var array
43-
*/
44-
protected $dates = [
45-
'expires_at',
37+
'expires_at' => 'datetime',
4638
];
4739

4840
/**

src/Bridge/AccessTokenRepository.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use DateTime;
66
use Illuminate\Contracts\Events\Dispatcher;
77
use Laravel\Passport\Events\AccessTokenCreated;
8+
use Laravel\Passport\Passport;
89
use Laravel\Passport\TokenRepository;
910
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
1011
use League\OAuth2\Server\Entities\ClientEntityInterface;
@@ -46,7 +47,7 @@ public function __construct(TokenRepository $tokenRepository, Dispatcher $events
4647
*/
4748
public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null)
4849
{
49-
return new AccessToken($userIdentifier, $scopes, $clientEntity);
50+
return new Passport::$accessTokenEntity($userIdentifier, $scopes, $clientEntity);
5051
}
5152

5253
/**

src/Bridge/PersonalAccessGrant.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,22 @@ public function respondToAccessTokenRequest(
2020
// Validate request
2121
$client = $this->validateClient($request);
2222
$scopes = $this->validateScopes($this->getRequestParameter('scope', $request));
23+
$userIdentifier = $this->getRequestParameter('user_id', $request);
2324

2425
// Finalize the requested scopes
25-
$scopes = $this->scopeRepository->finalizeScopes($scopes, $this->getIdentifier(), $client);
26+
$scopes = $this->scopeRepository->finalizeScopes(
27+
$scopes,
28+
$this->getIdentifier(),
29+
$client,
30+
$userIdentifier
31+
);
2632

2733
// Issue and persist access token
2834
$accessToken = $this->issueAccessToken(
29-
$accessTokenTTL, $client,
30-
$this->getRequestParameter('user_id', $request), $scopes
35+
$accessTokenTTL,
36+
$client,
37+
$userIdentifier,
38+
$scopes
3139
);
3240

3341
// Inject access token into response type

src/Bridge/ScopeRepository.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,31 @@
22

33
namespace Laravel\Passport\Bridge;
44

5+
use Laravel\Passport\ClientRepository;
56
use Laravel\Passport\Passport;
67
use League\OAuth2\Server\Entities\ClientEntityInterface;
78
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
89

910
class ScopeRepository implements ScopeRepositoryInterface
1011
{
12+
/**
13+
* The client repository.
14+
*
15+
* @var \Laravel\Passport\ClientRepository|null
16+
*/
17+
protected ?ClientRepository $clients;
18+
19+
/**
20+
* Create a new scope repository.
21+
*
22+
* @param \Laravel\Passport\ClientRepository|null $clients
23+
* @return void
24+
*/
25+
public function __construct(?ClientRepository $clients = null)
26+
{
27+
$this->clients = $clients;
28+
}
29+
1130
/**
1231
* {@inheritdoc}
1332
*/
@@ -31,8 +50,12 @@ public function finalizeScopes(
3150
})->values()->all();
3251
}
3352

53+
$client = $this->clients?->findActive($clientEntity->getIdentifier());
54+
3455
return collect($scopes)->filter(function ($scope) {
3556
return Passport::hasScope($scope->getIdentifier());
57+
})->when($client, function ($scopes, $client) {
58+
return $scopes->filter(fn ($scope) => $client->hasScope($scope->getIdentifier()));
3659
})->values()->all();
3760
}
3861
}

0 commit comments

Comments
 (0)