Delete token if it is past its lifetime

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-08-07 11:41:38 +02:00
parent 921198aad0
commit 6912299808
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -30,6 +30,9 @@ use OCP\IDBConnection;
use OCP\Security\ISecureRandom;
class AssetMapper extends Mapper {
/** @var int Limetime of a token is 10 minutes */
const tokenLifeTime = 600;
/** @var ISecureRandom */
private $random;
@ -80,6 +83,14 @@ class AssetMapper extends Mapper {
throw new DoesNotExistException('No asset for token found');
}
return Asset::fromRow($data);
$asset = Asset::fromRow($data);
// Check the token lifetime
if ($asset->getTimestamp() + self::tokenLifeTime < $this->time->getTime()) {
$this->delete($asset);
throw new DoesNotExistException('No asset for token found');
}
return $asset;
}
}