PluginProbe
Authorizer / 3.9.1
Authorizer v3.9.1
3.16.0 3.15.3 3.15.2 3.15.1 3.15.0 3.14.3 3.14.4 3.14.2 3.14.1 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.10 2.9.11 2.9.12 2.9.13 2.9.2 2.9.3 All 127 releases
← All changes | vendor/firebase/php-jwt/src/CachedKeySet.php +6 -23 3.15.13.9.1 View file →
@@ -79,11 +79,11 @@
79 79 string $jwksUri,
80 80 ClientInterface $httpClient,
81 81 RequestFactoryInterface $httpFactory,
82 82 CacheItemPoolInterface $cache,
83 - ?int $expiresAfter = null,
83 + int $expiresAfter = null,
84 84 bool $rateLimit = false,
85 - ?string $defaultAlg = null
85 + string $defaultAlg = null
86 86 ) {
87 87 $this->jwksUri = $jwksUri;
88 88 $this->httpClient = $httpClient;
89 89 $this->httpFactory = $httpFactory;
@@ -177,19 +177,8 @@
177 177 return false;
178 178 }
179 179 $request = $this->httpFactory->createRequest('GET', $this->jwksUri);
180 180 $jwksResponse = $this->httpClient->sendRequest($request);
181 - if ($jwksResponse->getStatusCode() !== 200) {
182 - throw new UnexpectedValueException(
183 - \sprintf(
184 - 'HTTP Error: %d %s for URI "%s"',
185 - $jwksResponse->getStatusCode(),
186 - $jwksResponse->getReasonPhrase(),
187 - $this->jwksUri,
188 - ),
189 - $jwksResponse->getStatusCode()
190 - );
191 - }
192 181 $this->keySet = $this->formatJwksForCache((string) $jwksResponse->getBody());
193 182
194 183 if (!isset($this->keySet[$keyId])) {
195 184 return false;
@@ -212,23 +201,17 @@
212 201 return false;
213 202 }
214 203
215 204 $cacheItem = $this->cache->getItem($this->rateLimitCacheKey);
216 -
217 - $cacheItemData = [];
218 - if ($cacheItem->isHit() && \is_array($data = $cacheItem->get())) {
219 - $cacheItemData = $data;
205 + if (!$cacheItem->isHit()) {
206 + $cacheItem->expiresAfter(1); // # of calls are cached each minute
220 207 }
221 208
222 - $callsPerMinute = $cacheItemData['callsPerMinute'] ?? 0;
223 - $expiry = $cacheItemData['expiry'] ?? new \DateTime('+60 seconds', new \DateTimeZone('UTC'));
224 -
209 + $callsPerMinute = (int) $cacheItem->get();
225 210 if (++$callsPerMinute > $this->maxCallsPerMinute) {
226 211 return true;
227 212 }
228 -
229 - $cacheItem->set(['expiry' => $expiry, 'callsPerMinute' => $callsPerMinute]);
230 - $cacheItem->expiresAt($expiry);
213 + $cacheItem->set($callsPerMinute);
231 214 $this->cache->save($cacheItem);
232 215 return false;
233 216 }
234 217