File tree 2 files changed +9
-12
lines changed
2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -132,13 +132,13 @@ public function offsetUnset($offset): void
132
132
133
133
private function keyIdExists (string $ keyId ): bool
134
134
{
135
- $ keySetToCache = null ;
136
135
if (null === $ this ->keySet ) {
137
136
$ item = $ this ->getCacheItem ();
138
137
// Try to load keys from cache
139
138
if ($ item ->isHit ()) {
140
139
// item found! Return it
141
- $ this ->keySet = $ item ->get ();
140
+ $ jwks = $ item ->get ();
141
+ $ this ->keySet = JWK ::parseKeySet (json_decode ($ jwks , true ), $ this ->defaultAlg );
142
142
}
143
143
}
144
144
@@ -148,17 +148,15 @@ private function keyIdExists(string $keyId): bool
148
148
}
149
149
$ request = $ this ->httpFactory ->createRequest ('get ' , $ this ->jwksUri );
150
150
$ jwksResponse = $ this ->httpClient ->sendRequest ($ request );
151
- $ jwks = json_decode (( string ) $ jwksResponse ->getBody (), true );
152
- $ this ->keySet = $ keySetToCache = JWK ::parseKeySet ($ jwks , $ this ->defaultAlg );
151
+ $ jwks = ( string ) $ jwksResponse ->getBody ();
152
+ $ this ->keySet = JWK ::parseKeySet (json_decode ( $ jwks, true ) , $ this ->defaultAlg );
153
153
154
154
if (!isset ($ this ->keySet [$ keyId ])) {
155
155
return false ;
156
156
}
157
- }
158
157
159
- if ($ keySetToCache ) {
160
158
$ item = $ this ->getCacheItem ();
161
- $ item ->set ($ keySetToCache );
159
+ $ item ->set ($ jwks );
162
160
if ($ this ->expiresAfter ) {
163
161
$ item ->expiresAfter ($ this ->expiresAfter );
164
162
}
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ public function testKeyIdIsCached()
117
117
$ cacheItem ->isHit ()
118
118
->willReturn (true );
119
119
$ cacheItem ->get ()
120
- ->willReturn (JWK :: parseKeySet ( json_decode ( $ this ->testJwks1 , true )) );
120
+ ->willReturn ($ this ->testJwks1 );
121
121
122
122
$ cache = $ this ->prophesize (CacheItemPoolInterface::class);
123
123
$ cache ->getItem ($ this ->testJwksUriKey )
@@ -143,7 +143,7 @@ public function testCachedKeyIdRefresh()
143
143
->willReturn (true );
144
144
$ cacheItem ->get ()
145
145
->shouldBeCalledOnce ()
146
- ->willReturn (JWK :: parseKeySet ( json_decode ( $ this ->testJwks1 , true )) );
146
+ ->willReturn ($ this ->testJwks1 );
147
147
$ cacheItem ->set (Argument::any ())
148
148
->shouldBeCalledOnce ()
149
149
->will (function () {
@@ -217,9 +217,8 @@ public function testJwtVerify()
217
217
$ cacheItem ->isHit ()
218
218
->willReturn (true );
219
219
$ cacheItem ->get ()
220
- ->willReturn (JWK ::parseKeySet (
221
- json_decode (file_get_contents (__DIR__ . '/data/rsa-jwkset.json ' ), true )
222
- ));
220
+ ->willReturn (file_get_contents (__DIR__ . '/data/rsa-jwkset.json ' )
221
+ );
223
222
224
223
$ cache = $ this ->prophesize (CacheItemPoolInterface::class);
225
224
$ cache ->getItem ($ this ->testJwksUriKey )
You can’t perform that action at this time.
0 commit comments