Slick.php
/**
     * Validates the signature of an incoming request from Slack.
     *
     * @param string $key
     * @param string $signature
     * @param int $time
     * @param string $body
     * @throws Exception if signature validation fails
     */
Validates the signature of an incoming request from Slack.
Validates the signature of an incoming request from Slack .
public static function validateSignature(string $key, string $signature, int $time, string $body): void
    {
        if (abs(time() - $time) > 300) {
            self::err('auth', 'Timestamp is too old or too new (clock skew / time drift)', 401);
        }
        if (substr($signature, 0, 3) !== 'v0=') {
            self::err('auth', 'Missing or unsupported signature version', 401);
        }
        $expectedSignature = 'v0=' . hash_hmac('sha256', "v0:{$time}:{$body}", $key);
        if (!hash_equals($signature, $expectedSignature)) {
            self::err('auth', 'Signature (v0) failed validation', 401);
        }
    }
public static function validateSignature ( string $ key , string $ signature , int $ time , string $ body ) : void { if ( abs ( time ( ) - $ time ) > 300 ) { self :: err ( 'auth' , 'Timestamp is too old or too new (clock skew / time drift)' , 401 ) ; } if ( substr ( $ signature , 0 , 3 ) !== 'v0=' ) { self :: err ( 'auth' , 'Missing or unsupported signature version' , 401 ) ; } $ expectedSignature = 'v0=' . hash_hmac ( 'sha256' , " v0: { $ time } : { $ body } " , $ key ) ; if ( ! hash_equals ( $ signature , $ expectedSignature ) ) { self :: err ( 'auth' , 'Signature (v0) failed validation' , 401 ) ; } }
Validates the signature of an incoming request from Slack.
Validates the signature of an incoming request from Slack .