Skip to content

Commit 35f9e96

Browse files
authored
Laravel 12 Support (#184)
1 parent a782f5d commit 35f9e96

File tree

7 files changed

+38
-9
lines changed

7 files changed

+38
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
9+
## [v11.2.0] - 2025-02-24
10+
### Added
11+
- Support for Laravel 12 has been added.
12+
913
## [v11.1.0] - 2024-07-17
1014
### Changed
1115
- For Azure Entra ID SSO, a new `token_verifier` option has been added to facilitate multi-tenant configurations.

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
"northwestern-sysdev/event-hub-php-sdk": "^3.0",
2121
"laravel/ui": "^3.0|^2.0|^4.0",
2222
"lcobucci/jwt": "^4.0",
23-
"socialiteproviders/manager": "~4.0",
24-
"firebase/php-jwt": "^5.3"
23+
"socialiteproviders/manager": "~4.8.1",
24+
"firebase/php-jwt": "^6"
2525
},
2626
"require-dev": {
27-
"orchestra/testbench": "~9.0",
27+
"orchestra/testbench": "^10.0",
2828
"php-coveralls/php-coveralls": "^2.4",
29-
"phpunit/phpunit": "^10.0",
29+
"phpunit/phpunit": "^11.0",
3030
"laravel/pint": "^1.13",
31-
"larastan/larastan": "^2.0"
31+
"larastan/larastan": "^3.0"
3232
},
3333
"autoload": {
3434
"psr-4": {

src/Auth/OAuth2/NorthwesternAzureProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Illuminate\Support\Str;
99
use Laravel\Socialite\Two\InvalidStateException;
1010
use Laravel\Socialite\Two\User as TwoUser;
11-
use Lcobucci\JWT\UnencryptedToken;
1211
use Northwestern\SysDev\SOA\Auth\OAuth2\TokenVerifier\Contract\TokenVerifierInterface;
1312
use SocialiteProviders\Manager\OAuth2\AbstractProvider;
1413
use SocialiteProviders\Manager\OAuth2\User;

src/Auth/OAuth2/TokenVerifier/Contract/AbstractAzureTokenVerifier.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,29 @@ public function parseAndVerify(string $jwt): UnencryptedToken
4343

4444
$data = $this->loadKeys();
4545

46-
$publicKeys = JWK::parseKeySet($data);
46+
/**
47+
* This is kind of jank, but the `alg` claim in the JWK is not required by the spec, so Microsoft has opted
48+
* not to include it.
49+
*
50+
* As of v6, the JWT library requires either the alg to be provided -or- a default given, to mitigate
51+
* CVE-2021-46743, a key type confusion attack. The CVE is probably broadly applicable to any implementation
52+
* dealing with these keys missing their `alg` claims.
53+
*
54+
* If Microsoft updates in the future, they will hopefully start providing the `alg` claim on the new keys in
55+
* the keyring. In that case, this will continue to work just fine, since the `alg` claim has priority over
56+
* this default.
57+
*
58+
* @see https://github.com/firebase/php-jwt/issues/498
59+
* @see https://github.com/advisories/GHSA-8xf4-w7qw-pjjw
60+
* @see https://github.com/firebase/php-jwt/issues/351
61+
*/
62+
$defaultAlgorithm = 'RS256';
63+
64+
$publicKeys = JWK::parseKeySet($data, $defaultAlgorithm);
4765
$kid = $token->headers()->get('kid');
4866

4967
if (isset($publicKeys[$kid])) {
50-
$publicKey = openssl_pkey_get_details($publicKeys[$kid]);
68+
$publicKey = openssl_pkey_get_details($publicKeys[$kid]->getKeyMaterial());
5169
$constraints = [
5270
new SignedWith(new Sha256(), InMemory::plainText($publicKey['key'])),
5371
new LooseValidAt(SystemClock::fromSystemTimezone()),

src/Auth/WebSSOAuthentication.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
use Northwestern\SysDev\SOA\Auth\Strategy\NoSsoSession;
1919
use Northwestern\SysDev\SOA\Auth\Strategy\WebSSOStrategy;
2020

21+
/**
22+
* @phpstan-ignore trait.unused
23+
*/
2124
trait WebSSOAuthentication
2225
{
2326
use RedirectsUsers, WebSSORoutes;

src/Auth/WebSSORoutes.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Northwestern\SysDev\SOA\Auth;
44

5+
/**
6+
* @phpstan-ignore trait.unused
7+
*/
58
trait WebSSORoutes
69
{
710
/** Route name for your login page */

src/Console/Commands/MakeWebSSO.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ class MakeWebSSO extends GeneratorCommand
1212

1313
protected $type = 'Controller';
1414

15-
public function handle()
15+
public function handle(): ?bool
1616
{
1717
parent::handle();
1818

1919
$this->ejectRoutes();
20+
21+
return true;
2022
}
2123

2224
protected function getNameInput()

0 commit comments

Comments
 (0)