增加回调log
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Extend\TencentVideo;
|
||||
|
||||
use App\Exception\BusinessException;
|
||||
|
||||
class Safe extends Base
|
||||
{
|
||||
/**
|
||||
* 获取用户签名
|
||||
* @param string $user_id
|
||||
* @return string
|
||||
*/
|
||||
public function getUserSign(string $user_id = ""): string
|
||||
{
|
||||
return parent::getUserSign($user_id); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证回调签名
|
||||
* @param string $body 请求内容提
|
||||
* @param string $sign 签名
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSign(string $body, string $sign): bool
|
||||
{
|
||||
$token = config('video.token');
|
||||
if (empty($token)) {
|
||||
throw new BusinessException("Video Token Config Error");
|
||||
}
|
||||
|
||||
$hash = hash_hmac( 'sha256', $body, $token, true );
|
||||
|
||||
$sys_sign = base64_encode($hash);
|
||||
if ($sign != $sys_sign) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user