public function verifyWebhookSignature() {

        $timestamp = $this->request->input('timestamp');
        $token     = $this->request->input('token');
        $signature = $this->request->input('signature');


        // The Mailgun config param is an array, so grab the full array
        $configMailgun = config('services.mailgun');

        $hmac = hash_hmac('sha256', $timestamp. $token, $configMailgun['secret']);

        if(function_exists('hash_equals')) {

            // hash_equals is constant time, but will not be introduced until PHP 5.6
            return hash_equals($hmac, $signature);
        }

        return ($hmac == $signature);
    }
public function verifyWebhookSignature() {

        $timestamp = $this->request->input('timestamp');
        $token     = $this->request->input('token');
        $signature = $this->request->input('signature');


        // The Mailgun config param is an array, so grab the full array
        $configMailgun = config('services.mailgun');

        $hmac = hash_hmac('sha256', $timestamp. $token, $configMailgun['secret']);

        if(function_exists('hash_equals')) {

            // hash_equals is constant time, but will not be introduced until PHP 5.6
            return hash_equals($hmac, $signature);
        }

        return ($hmac == $signature);
    }
public function verifyWebhookSignature ( ) { $ timestamp = $ this -> request -> input ( 'timestamp' ) ; $ token = $ this -> request -> input ( 'token' ) ; $ signature = $ this -> request -> input ( 'signature' ) ; // The Mailgun config param is an array, so grab the full array $ configMailgun = config ( 'services.mailgun' ) ; $ hmac = hash_hmac ( 'sha256' , $ timestamp . $ token , $ configMailgun [ 'secret' ] ) ; if ( function_exists ( 'hash_equals' ) ) { // hash_equals is constant time, but will not be introduced until PHP 5.6 return hash_equals ( $ hmac , $ signature ) ; } return ( $ hmac == $ signature ) ; }
Ensure the authenticity of inbound Mailgun request

https://documentation.mailgun.com/user_manual.html#webhooks
https://github.com/mailgun/mailgun-php/blob/master/src/Mailgun/Mailgun.php
http://php.net/manual/en/function.hash-hmac.php

@param  timestamp  $timestamp  Mailgun's timestamp in the POST request
@param  string     $token      Mailguns's token in the POST request
@paraam string     $signature  Mailgun's signature in the POST request
@return bool
Ensure the authenticity of inbound Mailgun request