This commit is contained in:
wucongxing 2024-01-31 09:12:27 +08:00
parent 13491ac601
commit fcfb84e6c6
2 changed files with 31 additions and 14 deletions

View File

@ -1711,10 +1711,9 @@ class CallBackController extends AbstractController
*/
public function trtcRoomCallBack(): ResponseInterface
{
$request_params = $this->request->all();
$request_params = $this->request->getBody()->getContents();
$SdkAppId = $this->request->header("SdkAppId");
$Sign = $this->request->header("Sign");
try {
Log::getInstance("CallBackController-trtcRoomCallBack")->info(json_encode($request_params, JSON_UNESCAPED_UNICODE));
Log::getInstance("CallBackController-trtcRoomCallBack")->info(json_encode($SdkAppId, JSON_UNESCAPED_UNICODE));
@ -1728,15 +1727,19 @@ class CallBackController extends AbstractController
return $this->TrtcErrorReturn("缺少签名字段");
}
// // 鉴定回调签名
// $VideoSafe = new VideoSafe();
// $result = $VideoSafe->validateSign($request_params,$Sign);
// 鉴定回调签名
$VideoSafe = new VideoSafe();
$result = $VideoSafe->validateSign($request_params,$Sign);
dump($result);
// if (!$result) {
// return $this->ImErrorReturn("回调签名不匹配");
// return $this->TrtcErrorReturn("回调签名不匹配");
// }
$request_params = json_decode($request_params,true);
die;
if (empty($request_params['CallbackCommand'])){
if (empty($request_params['EventGroupId'])){
return $this->ImErrorReturn("回调事件为空");
}
@ -1767,14 +1770,14 @@ class CallBackController extends AbstractController
}
/**
* 音视频回调-房间
* 音视频回调-媒体
* @return ResponseInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function trtcMediaCallBack(): ResponseInterface
{
$request_params = $this->request->all();
$request_params = $this->request->getBody()->getContents();
$SdkAppId = $this->request->header("SdkAppId");
$Sign = $this->request->header("Sign");
@ -1791,12 +1794,24 @@ class CallBackController extends AbstractController
return $this->TrtcErrorReturn("缺少签名字段");
}
// // 鉴定回调签名
// $VideoSafe = new VideoSafe();
// $result = $VideoSafe->validateSign($request_params,$Sign);
// 鉴定回调签名
$VideoSafe = new VideoSafe();
$result = $VideoSafe->validateSign($request_params,$Sign);
dump($result);
// if (!$result) {
// return $this->ImErrorReturn("回调签名不匹配");
// return $this->TrtcErrorReturn("回调签名不匹配");
// }
$request_params = json_decode($request_params,true);
die;
// 鉴定回调签名
$VideoSafe = new VideoSafe();
$result = $VideoSafe->validateSign($request_params,$Sign);
if (!$result) {
return $this->TrtcErrorReturn("回调签名不匹配");
}
die;
if (empty($request_params['CallbackCommand'])){

View File

@ -29,9 +29,11 @@ class Safe extends Base
throw new BusinessException("Video Token Config Error");
}
$hash = hash_hmac( 'sha256', $body, $token, true );
$hash = hash_hmac( 'sha256', $body, "123654", true );
$sys_sign = base64_encode($hash);
dump($sign);
dump($sys_sign);
if ($sign != $sys_sign) {
return false;
}