Skip to content

Commit 3209af3

Browse files
authored
Fix breaking change with php-jwt 6.1.0 (#311)
Hi! The latest release of php-jwt (6.1.0) breaks the oAuthJWT method. `Forrest::authenticate(); ` throw an error: ``` TypeError Firebase\JWT\JWT::encode(): Argument #4 ($keyId) must be of type ?string, array given, called in *****/vendor/omniphx/forrest/src/Omniphx/Forrest/Authentications/OAuthJWT.php on line 22 ``` Checking these changes I see that the `alg` param is the third only and it's not necessary to pass it as fourth param (which is the KeyId param) so I removed the $header variable/param. https://github.com/firebase/php-jwt/blob/fbb2967a3a68b07e37678c00c0cf51165051495f/src/JWT.php#L182
1 parent 34d9fd4 commit 3209af3

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/Omniphx/Forrest/Authentications/OAuthJWT.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ class OAuthJWT extends BaseAuthentication implements AuthenticationInterface
1111
{
1212
public static function getJWT($iss, $aud, $sub, $privateKey)
1313
{
14-
$header = ['alg' => 'RS256'];
1514
$payload = [
1615
'iss' => $iss,
1716
'aud' => $aud,
1817
'sub' => $sub,
1918
'exp' => Carbon::now()->addMinutes(3)->timestamp
2019
];
2120

22-
return JWT::encode($payload, $privateKey, 'RS256', $header);
21+
return JWT::encode($payload, $privateKey, 'RS256');
2322
}
2423

2524
public function authenticate($url = null)

0 commit comments

Comments
 (0)