src/SignatureVerifier.php
public static function verifyNotificationSignature($body, $timestamp, $signature, $validFor = 7200)
    {
        $paramsArray = [
            'body'      => $body,
            'timestamp' => $timestamp,
            'signature' => $signature,
            'validFor'  => $validFor
        ];

        self::validateParams($paramsArray, self::$NOTIFICATION_VALIDATOR_ALLOWED_TYPES);

        if (time() - $timestamp > $validFor) {
            return false;
        }

        $apiSecret = \Cloudinary::config_get('api_secret');
        self::validateApiSecret($apiSecret);

        $payloadToSign = $body . $timestamp;
        $hmac = self::generateHmac($payloadToSign, $apiSecret);

        if ($hmac !== $signature) {
            return false;
        }

        return true;
    }
public static function verifyNotificationSignature($body, $timestamp, $signature, $validFor = 7200)
    {
        $paramsArray = [
            'body'      => $body,
            'timestamp' => $timestamp,
            'signature' => $signature,
            'validFor'  => $validFor
        ];

        self::validateParams($paramsArray, self::$NOTIFICATION_VALIDATOR_ALLOWED_TYPES);

        if (time() - $timestamp > $validFor) {
            return false;
        }

        $apiSecret = \Cloudinary::config_get('api_secret');
        self::validateApiSecret($apiSecret);

        $payloadToSign = $body . $timestamp;
        $hmac = self::generateHmac($payloadToSign, $apiSecret);

        if ($hmac !== $signature) {
            return false;
        }

        return true;
    }
public static function verifyNotificationSignature ( $ body , $ timestamp , $ signature , $ validFor = 7200 ) { $ paramsArray = [ 'body' => $ body , 'timestamp' => $ timestamp , 'signature' => $ signature , 'validFor' => $ validFor ] ; self :: validateParams ( $ paramsArray , self :: $ NOTIFICATION_VALIDATOR_ALLOWED_TYPES ) ; if ( time ( ) - $ timestamp > $ validFor ) { return false ; } $ apiSecret = \ Cloudinary :: config_get ( 'api_secret' ) ; self :: validateApiSecret ( $ apiSecret ) ; $ payloadToSign = $ body . $ timestamp ; $ hmac = self :: generateHmac ( $ payloadToSign , $ apiSecret ) ; if ( $ hmac !== $ signature ) { return false ; } return true ; }
Verifies the authenticity of a notification signature

@param string        $body       Json of the request's body
@param int|string    $timestamp  Unix timestamp. Can be retrieved from the X-Cld-Timestamp header
@param string        $signature  Actual signature. Can be retrieved from the X-Cld-Signature header
@param int|string    $validFor  The desired time in seconds for considering the request valid

@return boolean

@throws \InvalidArgumentException In case a mandatory parameter is empty or of wrong type
Verifies the authenticity of a notification signature