Added expiry logging and fixed token caching
This commit is contained in:
@@ -120,7 +120,7 @@ class OAuth2AuthServer {
|
|||||||
$grantCacheKey = sha1(json_encode($params));
|
$grantCacheKey = sha1(json_encode($params));
|
||||||
|
|
||||||
$ts = microtime(true);
|
$ts = microtime(true);
|
||||||
$tokenResponse = json_decode($this->cacheAndLog->getFromCacheCustom($grantCacheKey));
|
$tokenResponse = json_decode($this->cacheAndLog->getFromCacheCustom($grantCacheKey), true);
|
||||||
|
|
||||||
if (isset($tokenResponse)) {
|
if (isset($tokenResponse)) {
|
||||||
$this->cacheAndLog->logInfoWithTime("Reused access token for <".$this->authServer->getId()."> from cache.", $ts);
|
$this->cacheAndLog->logInfoWithTime("Reused access token for <".$this->authServer->getId()."> from cache.", $ts);
|
||||||
@@ -134,7 +134,7 @@ class OAuth2AuthServer {
|
|||||||
|
|
||||||
$expiry = isset($tokenResponse['expires_in']) ? $tokenResponse['expires_in'] : 84600;
|
$expiry = isset($tokenResponse['expires_in']) ? $tokenResponse['expires_in'] : 84600;
|
||||||
|
|
||||||
$this->cacheAndLog->logInfoWithTime("Retrieved access token for <".$this->authServer->getId()."> from token endpoint.", $ts);
|
$this->cacheAndLog->logInfoWithTime("Retrieved access token for <".$this->authServer->getId()."> from token endpoint and will cache for ".$expiry." seconds.", $ts);
|
||||||
$this->cacheAndLog->putIntoCacheCustom($grantCacheKey, json_encode($tokenResponse), $expiry);
|
$this->cacheAndLog->putIntoCacheCustom($grantCacheKey, json_encode($tokenResponse), $expiry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user