Skip to content

Commit dcbb2c5

Browse files
committed
2.0.0: Migrate from tymon/jwt to PHP-Open-Source-Saver/jwt-auth. Support >=PHP8.0 and October CMS v3.
1 parent a59aca7 commit dcbb2c5

12 files changed

+65
-27
lines changed

Plugin.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use ReaZzon\JWTAuth\Classes\Events\UserModelHandler;
2121

2222
use System\Classes\PluginManager;
23-
use Tymon\JWTAuth\Providers\LaravelServiceProvider;
23+
use PHPOpenSourceSaver\JWTAuth\Providers\LaravelServiceProvider;
2424

2525
/**
2626
* JWTAuth Plugin Information File
@@ -136,7 +136,8 @@ private function registerJWT(): void
136136
$guard = new JWTGuard(
137137
$app['tymon.jwt'],
138138
new UserProvider(app(UserPluginResolverContract::class)->getModel()),
139-
$app['request']
139+
$app['request'],
140+
new \October\Rain\Events\Dispatcher()
140141
);
141142

142143
$app->refresh('request', $guard, 'setRequest');

classes/UserPluginResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Model;
77
use ReaZzon\JWTAuth\Classes\Contracts\Plugin;
88
use System\Classes\PluginManager;
9-
use Tymon\JWTAuth\Contracts\JWTSubject;
9+
use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
1010
use October\Rain\Support\Traits\Singleton;
1111
use October\Rain\Auth\Manager as AuthManager;
1212
use ReaZzon\JWTAuth\Classes\Contracts\UserPluginResolver as UserPluginResolverContract;

classes/behaviors/UserSubjectBehavior.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace ReaZzon\JWTAuth\Classes\Behaviors;
44

55
use October\Rain\Database\ModelBehavior;
6-
use Tymon\JWTAuth\Contracts\JWTSubject;
6+
use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
77

88
/**
99
* Class UserSubjectBehavior

classes/contracts/Plugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ReaZzon\JWTAuth\Classes\Contracts;
55

6-
use Tymon\JWTAuth\Contracts\JWTSubject;
6+
use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
77
use Model;
88

99
/**

classes/contracts/UserPluginResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace ReaZzon\JWTAuth\Classes\Contracts;
55

66
use October\Rain\Auth\Manager as AuthManager;
7-
use Tymon\JWTAuth\Contracts\JWTSubject;
7+
use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
88
use Model;
99

1010
/**

classes/guards/JWTGuard.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use Illuminate\Contracts\Auth\Authenticatable;
44
use October\Rain\Auth\Models\User;
55
use ReaZzon\JWTAuth\Classes\Contracts\UserPluginResolver;
6-
use Tymon\JWTAuth\Contracts\JWTSubject;
7-
use Tymon\JWTAuth\JWTGuard as JWTGuardBase;
6+
use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
7+
use PHPOpenSourceSaver\JWTAuth\JWTGuard as JWTGuardBase;
88
use ReaZzon\JWTAuth\Classes\Behaviors\UserSubjectBehavior;
99

1010
/**

classes/resolvers/BuddiesPlugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Lovata\Toolbox\Models\Settings;
1212
use Lovata\Buddies\Models\User as BuddiesUserModel;
1313
use ReaZzon\JWTAuth\Models\BuddiesSettings;
14-
use Tymon\JWTAuth\Contracts\JWTSubject;
14+
use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
1515
use ReaZzon\JWTAuth\Classes\Contracts\Plugin;
1616
use ReaZzon\JWTAuth\Classes\Exception\PluginModelResolverException;
1717

classes/resolvers/RainlabPlugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use RainLab\User\Models\User as RainlabUserModel;
77
use ReaZzon\JWTAuth\Classes\Contracts\Plugin;
88
use ReaZzon\JWTAuth\Classes\Exception\PluginModelResolverException;
9-
use Tymon\JWTAuth\Contracts\JWTSubject;
9+
use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
1010
use Model;
1111

1212
/**

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"php": ">=7.4",
77
"ext-json": "*",
88
"composer/installers": "~1.0",
9-
"tymon/jwt-auth": "1.0.2"
9+
"php-open-source-saver/jwt-auth": "1.4.2"
1010
},
1111
"extra": {
1212
"laravel": {
1313
"dont-discover": [
14-
"tymon/jwt-auth"
14+
"php-open-source-saver/jwt-auth"
1515
]
1616
}
1717
}

config/jwt.php

+47-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of jwt-auth.
5-
*
6-
* (c) Sean Tymon <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
113
return [
124
/*
135
|--------------------------------------------------------------------------
@@ -22,7 +14,9 @@
2214
| since RSA and ECDSA use a private/public key combo (See below).
2315
|
2416
*/
17+
2518
'secret' => env('JWT_SECRET'),
19+
2620
/*
2721
|--------------------------------------------------------------------------
2822
| JWT Authentication Keys
@@ -39,6 +33,7 @@
3933
| RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
4034
|
4135
*/
36+
4237
'keys' => [
4338
/*
4439
|--------------------------------------------------------------------------
@@ -50,7 +45,9 @@
5045
| E.g. 'file://path/to/public/key'
5146
|
5247
*/
48+
5349
'public' => env('JWT_PUBLIC_KEY'),
50+
5451
/*
5552
|--------------------------------------------------------------------------
5653
| Private Key
@@ -61,7 +58,9 @@
6158
| E.g. 'file://path/to/private/key'
6259
|
6360
*/
61+
6462
'private' => env('JWT_PRIVATE_KEY'),
63+
6564
/*
6665
|--------------------------------------------------------------------------
6766
| Passphrase
@@ -70,8 +69,10 @@
7069
| The passphrase for your private key. Can be null if none set.
7170
|
7271
*/
72+
7373
'passphrase' => env('JWT_PASSPHRASE'),
7474
],
75+
7576
/*
7677
|--------------------------------------------------------------------------
7778
| JWT time to live
@@ -87,6 +88,7 @@
8788
| Notice: If you set this to null you should remove 'exp' element from 'required_claims' list.
8889
|
8990
*/
91+
9092
'ttl' => env('JWT_TTL', 60),
9193

9294
/*
@@ -105,6 +107,7 @@
105107
| systems in place to revoke the token if necessary.
106108
|
107109
*/
110+
108111
'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
109112

110113
/*
@@ -118,7 +121,9 @@
118121
| for possible values.
119122
|
120123
*/
124+
121125
'algo' => env('JWT_ALGO', 'HS256'),
126+
122127
/*
123128
|--------------------------------------------------------------------------
124129
| Required Claims
@@ -129,6 +134,7 @@
129134
| present in the payload.
130135
|
131136
*/
137+
132138
'required_claims' => [
133139
'iss',
134140
'iat',
@@ -137,6 +143,7 @@
137143
'sub',
138144
'jti',
139145
],
146+
140147
/*
141148
|--------------------------------------------------------------------------
142149
| Persistent Claims
@@ -149,10 +156,12 @@
149156
| Note: If a claim does not exist then it will be ignored.
150157
|
151158
*/
159+
152160
'persistent_claims' => [
153161
// 'foo',
154162
// 'bar',
155163
],
164+
156165
/*
157166
|--------------------------------------------------------------------------
158167
| Lock Subject
@@ -169,7 +178,9 @@
169178
| a little on token size.
170179
|
171180
*/
181+
172182
'lock_subject' => true,
183+
173184
/*
174185
|--------------------------------------------------------------------------
175186
| Leeway
@@ -184,7 +195,9 @@
184195
| Specify in seconds - only if you know you need it.
185196
|
186197
*/
198+
187199
'leeway' => env('JWT_LEEWAY', 0),
200+
188201
/*
189202
|--------------------------------------------------------------------------
190203
| Blacklist Enabled
@@ -194,7 +207,9 @@
194207
| If you do not want or need this functionality, then set this to false.
195208
|
196209
*/
210+
197211
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
212+
198213
/*
199214
| -------------------------------------------------------------------------
200215
| Blacklist Grace Period
@@ -207,7 +222,20 @@
207222
| Set grace period in seconds to prevent parallel request failure.
208223
|
209224
*/
225+
210226
'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
227+
228+
/*
229+
|--------------------------------------------------------------------------
230+
| Show blacklisted token option
231+
|--------------------------------------------------------------------------
232+
|
233+
| Specify if you want to show black listed token exception on the laravel logs.
234+
|
235+
*/
236+
237+
'show_black_list_exception' => env('JWT_SHOW_BLACKLIST_EXCEPTION', 0),
238+
211239
/*
212240
|--------------------------------------------------------------------------
213241
| Cookies encryption
@@ -223,7 +251,9 @@
223251
| Set it to true if you want to decrypt cookies.
224252
|
225253
*/
254+
226255
'decrypt_cookies' => false,
256+
227257
/*
228258
|--------------------------------------------------------------------------
229259
| Providers
@@ -232,6 +262,7 @@
232262
| Specify the various providers used throughout the package.
233263
|
234264
*/
265+
235266
'providers' => [
236267
/*
237268
|--------------------------------------------------------------------------
@@ -241,7 +272,9 @@
241272
| Specify the provider that is used to create and decode the tokens.
242273
|
243274
*/
244-
'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class,
275+
276+
'jwt' => PHPOpenSourceSaver\JWTAuth\Providers\JWT\Lcobucci::class,
277+
245278
/*
246279
|--------------------------------------------------------------------------
247280
| Authentication Provider
@@ -250,7 +283,9 @@
250283
| Specify the provider that is used to authenticate users.
251284
|
252285
*/
253-
'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
286+
287+
'auth' => PHPOpenSourceSaver\JWTAuth\Providers\Auth\Illuminate::class,
288+
254289
/*
255290
|--------------------------------------------------------------------------
256291
| Storage Provider
@@ -259,6 +294,7 @@
259294
| Specify the provider that is used to store tokens in the blacklist.
260295
|
261296
*/
262-
'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
297+
298+
'storage' => PHPOpenSourceSaver\JWTAuth\Providers\Storage\Illuminate::class,
263299
],
264300
];

http/middlewares/ResolveUser.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace ReaZzon\JWTAuth\Http\Middlewares;
44

55
use ReaZzon\JWTAuth\Classes\Guards\JWTGuard;
6-
use Tymon\JWTAuth\Exceptions\JWTException;
7-
use Tymon\JWTAuth\Exceptions\UserNotDefinedException;
8-
use Tymon\JWTAuth\Exceptions\TokenBlacklistedException;
9-
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
6+
use PHPOpenSourceSaver\JWTAuth\Exceptions\JWTException;
7+
use PHPOpenSourceSaver\JWTAuth\Exceptions\UserNotDefinedException;
8+
use PHPOpenSourceSaver\JWTAuth\Exceptions\TokenBlacklistedException;
9+
use PHPOpenSourceSaver\JWTAuth\Exceptions\TokenExpiredException;
1010

1111
/**
1212
* Class ResolveUser

updates/version.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
1.0.1: First version of JWTAuth
2+
2.0.0: Migrate from tymon/jwt to PHP-Open-Source-Saver/jwt-auth. Support >=PHP8.0 and October CMS v3.

0 commit comments

Comments
 (0)