Skip to content

Commit b12e534

Browse files
committed
Add Laravel 9 support, drop jwt dep and parse it the old fashioned way
1 parent cbf728f commit b12e534

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor
22
.idea
33
composer.lock
4+
.phpunit.result.cache

composer.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
"require": {
77
"php": "^8.0",
88
"ext-curl": "*",
9-
"illuminate/support": "^8.0",
10-
"illuminate/http": "^8.0",
11-
"grantholle/pear-openid": "^1.0",
129
"ext-json": "*",
13-
"spatie/url": "^1.3|^2.0",
14-
"lcobucci/jwt": "^4.1"
10+
"grantholle/pear-openid": "^1.0",
11+
"illuminate/support": "^8.0|^9.0",
12+
"illuminate/http": "^8.0|^9.0",
13+
"spatie/url": "^1.3|^2.0"
1514
},
1615
"license": "MIT",
1716
"authors": [
@@ -36,6 +35,10 @@
3635
}
3736
},
3837
"require-dev": {
39-
"orchestra/testbench": "^6.22"
38+
"orchestra/testbench": "^7.0",
39+
"spatie/ray": "^1.33"
40+
},
41+
"scripts": {
42+
"test": "vendor/bin/phpunit"
4043
}
4144
}

src/Traits/AuthenticatesUsingPowerSchoolWithOidc.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Illuminate\Support\Collection;
1111
use Illuminate\Support\Facades\Http;
1212
use Illuminate\Support\Str;
13-
use Lcobucci\JWT\Configuration;
1413
use Spatie\Url\Url;
1514

1615
trait AuthenticatesUsingPowerSchoolWithOidc
@@ -127,11 +126,9 @@ public function login(Request $request)
127126
throw new OidcException("{$response['error']}: {$response['error_description']}");
128127
}
129128

130-
$dataSet = Configuration::forUnsecuredSigner()
131-
->parser()
132-
->parse($response['id_token'])
133-
->claims();
134-
$data = collect($dataSet->all());
129+
// This one-liner parses the jwt token without a library...
130+
$dataSet = json_decode(base64_decode(str_replace('_', '/', str_replace('-', '+', explode('.', $response['id_token'])[1]))));
131+
$data = collect($dataSet);
135132

136133
if (session()->pull('ps_oidc_nonce') !== $data->get('nonce')) {
137134
throw new OidcException('Invalid nonce. Please try logging in again.');

0 commit comments

Comments
 (0)