privateDecrypt($sign); if (!$sign || !$sign = json_decode($sign,true)){ return [false,'签名错误!']; } if (empty($sign['token']) || empty($sign['timestamp']) || empty($sign['timezone'])){ return [false,'签名参数错误!']; } if ($token != $sign['token']){ return [false,'签名参数校验错误!']; } if ($token != $sign['token']){ return [false,'签名参数校验错误!']; } // 根据客户端 时区 校验时间戳 $now = new \DateTime(null, new \DateTimeZone((string)$sign['timezone'])); $time = (int)($now->format('U')); // 如果 前端请求时间戳异常,则认为 请求被篡改 或 请求超时 if ($sign['timestamp'] <= ($time - self::deadTime)){ return [false,'签名过期,请求已过期!']; } // 请求唯一key $key = md5($sign['token'] . '_' .((string)$sign['timestamp'])); // redis 重复请求 if (!RedisUtil::getInstance('check_sign_lock',$key)->tryTimes(self::deadTime,1)) { return [false,'点的太快啦!']; } return [true,'success']; } }