新增手机号登录获取openid、新增身份认证科室验证
This commit is contained in:
+33
-1
@@ -7,6 +7,7 @@ use App\Exception\BusinessException;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
@@ -66,7 +67,7 @@ class Ca
|
||||
$option = [
|
||||
'form_params' => [
|
||||
'entityId' => $user_id, // 用户唯一标识,由业务系统定义
|
||||
'toSign' => json_encode($data,JSON_UNESCAPED_UNICODE),
|
||||
'toSign' => hash_hmac("sha1",json_encode($data,JSON_UNESCAPED_UNICODE),config("ca.secret")), // 签名原文
|
||||
'pin' => $pin, // 证书PIN码
|
||||
]
|
||||
];
|
||||
@@ -86,6 +87,34 @@ class Ca
|
||||
}
|
||||
}
|
||||
|
||||
// PKCS7签名验证接口
|
||||
// 对客户端签名信息进行验证,返回证书信息,同时可以配置回调服务,在验证成功后回调业务系统
|
||||
public function verifyPkcs7(string $sign_p7,array $data){
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
|
||||
$option = [
|
||||
'form_params' => [
|
||||
'opType' => "签名验证",
|
||||
'requestId' => $generator->generate(),// 业务流水号,唯一
|
||||
'signedData' => $sign_p7, // 签名值:签名接口返回的signP7
|
||||
'toSign' => hash_hmac("sha1",json_encode($data,JSON_UNESCAPED_UNICODE),config("ca.secret")), // 签名原文
|
||||
]
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->httpRequest(
|
||||
config("ca.api_url") . '/signgw-service/api/signature/verifyPkcs7',
|
||||
$option
|
||||
);
|
||||
if (empty($response)){
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
return $response;
|
||||
} catch (GuzzleException $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取请求签名
|
||||
* @param array $data
|
||||
@@ -117,6 +146,9 @@ class Ca
|
||||
];
|
||||
|
||||
$arg = array_merge($arg,$option);
|
||||
|
||||
// dump(json_encode($arg,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
$response = $this->client->post($path, $arg);
|
||||
if ($response->getStatusCode() != '200'){
|
||||
// 请求失败
|
||||
|
||||
Reference in New Issue
Block a user