Add validation for name and expiration in key creation
This commit is contained in:
parent
fa188fb27f
commit
6a922dcac2
1 changed files with 17 additions and 0 deletions
|
@ -99,6 +99,23 @@
|
||||||
throw new InvalidArgumentException('The name is too long');
|
throw new InvalidArgumentException('The name is too long');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($name !== null && empty($name))
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException('The name cannot be empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($expires !== null && $expires < time())
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException('The expiration time is in the past');
|
||||||
|
}
|
||||||
|
|
||||||
|
// At least more than 1 hour
|
||||||
|
if($expires !== null && $expires < time() + 3600)
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException('The expiration time is too soon, must be at least 1 hour in the future');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$uuid = UuidV4::v4()->toRfc4122();
|
$uuid = UuidV4::v4()->toRfc4122();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
Loading…
Add table
Reference in a new issue