Refactor ResolveSignature to improve UUID validation by reintroducing validation for 'signature_uuid' and throwing an InvalidRpcArgumentException for invalid UUIDs.
https://github.com/nosial/Socialbox-PHP/issues/44
This commit is contained in:
parent
df96d894a8
commit
a11c8b463f
2 changed files with 6 additions and 4 deletions
|
@ -35,10 +35,6 @@
|
|||
{
|
||||
throw new MissingRpcArgumentException('signature_uuid');
|
||||
}
|
||||
elseif(!Validator::validateUuid($rpcRequest->getParameter('signature_uuid')))
|
||||
{
|
||||
throw new InvalidRpcArgumentException('signature_uuid', 'Invalid UUID V4');
|
||||
}
|
||||
|
||||
return $rpcRequest->produceResponse(Socialbox::resolvePeerSignature(
|
||||
$rpcRequest->getParameter('peer'), $rpcRequest->getParameter('signature_uuid')
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
use Socialbox\Exceptions\RequestException;
|
||||
use Socialbox\Exceptions\ResolutionException;
|
||||
use Socialbox\Exceptions\RpcException;
|
||||
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
|
||||
use Socialbox\Exceptions\Standard\StandardRpcException;
|
||||
use Socialbox\Managers\ContactManager;
|
||||
use Socialbox\Managers\ExternalSessionManager;
|
||||
|
@ -910,6 +911,11 @@
|
|||
throw new StandardRpcException('Cannot resolve signature for a host peer', StandardError::FORBIDDEN);
|
||||
}
|
||||
|
||||
if(!Validator::validateUuid($signatureUuid))
|
||||
{
|
||||
throw new InvalidRpcArgumentException('The given signature UUID is not a valid UUID V4');
|
||||
}
|
||||
|
||||
// If the peer is registered within this server
|
||||
if($peerAddress->getDomain() === Configuration::getInstanceConfiguration()->getDomain())
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue