@@ -1051,14 +1051,11 @@ public function verifyJWTsignature($jwt) {
10511051 if (null === $ header || !\is_object ($ header )) {
10521052 throw new OpenIDConnectClientException ('Error decoding JSON from token header ' );
10531053 }
1054- $ payload = implode ('. ' , $ parts );
1055- $ jwks = json_decode ($ this ->fetchURL ($ this ->getProviderConfigValue ('jwks_uri ' )));
1056- if ($ jwks === NULL ) {
1057- throw new OpenIDConnectClientException ('Error decoding JSON from jwks_uri ' );
1058- }
10591054 if (!isset ($ header ->alg )) {
10601055 throw new OpenIDConnectClientException ('Error missing signature type in token header ' );
10611056 }
1057+
1058+ $ payload = implode ('. ' , $ parts );
10621059 switch ($ header ->alg ) {
10631060 case 'RS256 ' :
10641061 case 'PS256 ' :
@@ -1067,8 +1064,18 @@ public function verifyJWTsignature($jwt) {
10671064 $ hashtype = 'sha ' . substr ($ header ->alg , 2 );
10681065 $ signatureType = $ header ->alg === 'PS256 ' ? 'PSS ' : '' ;
10691066
1067+ if (isset ($ header ->jwk )) {
1068+ $ jwk = $ header ->jwk ;
1069+ } else {
1070+ $ jwks = json_decode ($ this ->fetchURL ($ this ->getProviderConfigValue ('jwks_uri ' )));
1071+ if ($ jwks === NULL ) {
1072+ throw new OpenIDConnectClientException ('Error decoding JSON from jwks_uri ' );
1073+ }
1074+ $ jwk = $ this ->getKeyForHeader ($ jwks ->keys , $ header );
1075+ }
1076+
10701077 $ verified = $ this ->verifyRSAJWTsignature ($ hashtype ,
1071- $ this -> getKeyForHeader ( $ jwks -> keys , $ header ) ,
1078+ $ jwk ,
10721079 $ payload , $ signature , $ signatureType );
10731080 break ;
10741081 case 'HS256 ' :
0 commit comments