Skip to content

Commit 81c92b0

Browse files
committed
Merge branch '9.x'
2 parents 9687b55 + 683becd commit 81c92b0

File tree

6 files changed

+105
-3
lines changed

6 files changed

+105
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77

88
### Added
99
- Allow client credentials secret to be hashed ([#1145](https://github.com/laravel/passport/pull/1145), [ccbcfeb](https://github.com/laravel/passport/commit/ccbcfeb5301e8f757395ba0e43980615acf4385e), [1c40ae0](https://github.com/laravel/passport/commit/1c40ae07503aeb23173d48f3a6e5757cafcfd71b))
10+
- Implement `passport:hash` command ([#1238](https://github.com/laravel/passport/pull/1238))
1011
- Initial support for multiple providers ([#1220](https://github.com/laravel/passport/pull/1220))
1112

1213
### Changed
1314
- Client credentials middleware should allow any valid client ([#1132](https://github.com/laravel/passport/pull/1132))
1415
- Switch from `getKey()` to `getAuthIdentifier()` to match Laravel core ([#1134](https://github.com/laravel/passport/pull/1134))
1516
- Use Hasher interface instead of HashManager ([#1157](https://github.com/laravel/passport/pull/1157))
17+
- Bump league server dependency ([#1237](https://github.com/laravel/passport/pull/1237))
1618

1719
### Removed
1820
- Remove deprecated functionality ([#1235](https://github.com/laravel/passport/pull/1235))
21+
- Drop support for old JWT versions ([#1236](https://github.com/laravel/passport/pull/1236))
1922

2023

2124
## [v8.5.0 (2020-05-05)](https://github.com/laravel/passport/compare/v8.4.4...v8.5.0)

UPGRADE.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
# Upgrade Guide
22

3+
## Upgrading To 9.0 From 8.0
4+
5+
### Support For Multiple Guards
6+
7+
PR: https://github.com/laravel/passport/pull/1220
8+
9+
Passport now has support for multiple guard user providers. Because of this change, you must add a `provider` column to the `oauth_clients` database table:
10+
11+
Schema::table('oauth_clients', function (Blueprint $table) {
12+
$table->string('provider')->after('secret')->nullable();
13+
});
14+
15+
### Client Credentials Secret Hashing
16+
17+
PR: https://github.com/laravel/passport/pull/1145
18+
19+
Client secrets may now be stored using a Bcrypt hash. However, before enabling this functionality, please consider the following. First, there is no way to reverse the hashing process once you have migrated your existing tokens. Secondly, when hashing client secrets, you will only have one opportunity to display the plain-text value to the user before it is hashed and stored in the database.
20+
21+
You may enable client secret hashing by calling the `Passport::hashClientSecrets()` method within the `boot` method of your `AppServiceProvider`. For convenience, we've included a new Artisan command which you can run to hash all existing client secrets:
22+
23+
php artisan passport:hash
24+
25+
**Again, please be aware that running this command cannot be undone. For extra precaution, you may wish to create a backup of your database before running the command.**
26+
27+
### Client Credentials Middleware Changes
28+
29+
PR: https://github.com/laravel/passport/pull/1132
30+
31+
[After a lengthy debate](https://github.com/laravel/passport/issues/1125), it was decided to revert the change made [in a previous PR](https://github.com/laravel/passport/pull/1040) that introduced an exception when the client credentials middleware was used to authenticate first party clients.
32+
33+
### Switch From `getKey` To `getAuthIdentifier`
34+
35+
PR: https://github.com/laravel/passport/pull/1134
36+
37+
Internally, Passport will now use the `getAuthIdentifier` method to determine a model's primary key. This is consistent with the framework and Laravel's first party libraries.
38+
39+
### Remove Deprecated Functionality
40+
41+
PR: https://github.com/laravel/passport/pull/1235
42+
43+
The deprecated `revokeOtherTokens` and `pruneRevokedTokens` methods and the `revokeOtherTokens` and `pruneRevokedTokens` properties were removed from the `Passport` object.
44+
45+
346
## Upgrading To 8.0 From 7.0
447

548
### Minimum & Upgraded Versions

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"require": {
1717
"php": "^7.2",
1818
"ext-json": "*",
19-
"firebase/php-jwt": "^3.0|^4.0|^5.0",
19+
"firebase/php-jwt": "^5.0",
2020
"guzzlehttp/guzzle": "^6.0",
2121
"illuminate/auth": "^6.0|^7.0",
2222
"illuminate/console": "^6.0|^7.0",
@@ -28,7 +28,7 @@
2828
"illuminate/http": "^6.0|^7.0",
2929
"illuminate/support": "^6.0|^7.0",
3030
"laminas/laminas-diactoros": "^2.2",
31-
"league/oauth2-server": "^8.0",
31+
"league/oauth2-server": "^8.1",
3232
"nyholm/psr7": "^1.0",
3333
"phpseclib/phpseclib": "^2.0",
3434
"symfony/psr-http-message-bridge": "^2.0"

src/Console/ClientCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,6 @@ protected function createAuthCodeClient(ClientRepository $clients)
162162
protected function outputClientDetails(Client $client)
163163
{
164164
$this->line('<comment>Client ID:</comment> '.$client->id);
165-
$this->line('<comment>Client secret:</comment> '.$client->secret);
165+
$this->line('<comment>Client secret:</comment> '.$client->plainSecret);
166166
}
167167
}

src/Console/HashCommand.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Laravel\Passport\Console;
4+
5+
use Illuminate\Console\Command;
6+
use Laravel\Passport\Passport;
7+
8+
class HashCommand extends Command
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'passport:hash';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'Hash all of the existing secrets in the clients table';
23+
24+
/**
25+
* Execute the console command.
26+
*
27+
* @return void
28+
*/
29+
public function handle()
30+
{
31+
if (! Passport::$hashesClientSecrets) {
32+
$this->warn('Please enable client hashing yet in your AppServiceProvider before continuning.');
33+
34+
return;
35+
}
36+
37+
if ($this->confirm('Are you sure you want to hash all client secrets? This cannot be undone.')) {
38+
$model = Passport::clientModel();
39+
40+
foreach ((new $model)->whereNotNull('secret')->cursor() as $client) {
41+
if (password_get_info($client->secret)['algo'] === PASSWORD_BCRYPT) {
42+
continue;
43+
}
44+
45+
$client->timestamps = false;
46+
47+
$client->forceFill([
48+
'secret' => password_hash($client->secret, PASSWORD_BCRYPT),
49+
])->save();
50+
}
51+
52+
$this->info('All client secrets were successfully hashed.');
53+
}
54+
}
55+
}

src/PassportServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function boot()
6262
$this->commands([
6363
Console\InstallCommand::class,
6464
Console\ClientCommand::class,
65+
Console\HashCommand::class,
6566
Console\KeysCommand::class,
6667
Console\PurgeCommand::class,
6768
]);

0 commit comments

Comments
 (0)