Skip to content

Commit 56d9733

Browse files
authored
BUGFIX: Prevent state cache from flooding the filesystem
Adjusts the `OAuthClient` such that it removes any state cache entries directly after usage. Additionally this change extends the garbage collection to remove expired state caches (to remove expired entries after failed or aborted authorizations) Fixes: #31
1 parent e6372e1 commit 56d9733

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Classes/OAuthClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ public function finishAuthorization(string $stateIdentifier, string $code, strin
359359
if (empty($stateFromCache)) {
360360
throw new OAuthClientException(sprintf('OAuth: Finishing authorization failed because oAuth state %s could not be retrieved from the state cache.', $stateIdentifier), 1558956494);
361361
}
362+
$this->stateCache->remove($stateIdentifier);
362363

363364
$authorizationId = $stateFromCache['authorizationId'];
364365
$clientId = $stateFromCache['clientId'];
@@ -619,6 +620,7 @@ public function shutdownObject(): void
619620
try {
620621
if (random_int(1, 100 * $factor) <= ($this->garbageCollectionProbability * $factor)) {
621622
$this->removeExpiredAuthorizations();
623+
$this->stateCache->collectGarbage();
622624
}
623625
} catch (\Exception $e) {
624626
}

0 commit comments

Comments
 (0)