初始化本地仓库
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\api\controller\system;
|
||||
|
||||
use app\api\controller\Base;
|
||||
use app\attribute\SkipApiEncrypt;
|
||||
use core\tool\ApiEncryptService;
|
||||
use core\tool\Json;
|
||||
use madong\swagger\annotation\response\DataResponse;
|
||||
use madong\swagger\attribute\AllowAnonymous;
|
||||
use OpenApi\Attributes as OA;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
#[SkipApiEncrypt]
|
||||
final class SecurityController extends Base
|
||||
{
|
||||
protected ApiEncryptService $encryptService;
|
||||
|
||||
public function __construct(ApiEncryptService $encryptService)
|
||||
{
|
||||
$this->encryptService = $encryptService;
|
||||
}
|
||||
|
||||
#[OA\Get(path: '/system/security/api-encrypt/public-key', summary: '获取接口加密公钥', tags: ['system-security'])]
|
||||
#[DataResponse(description: '获取成功')]
|
||||
#[AllowAnonymous(requireToken: false, requirePermission: false, description: '公共接口')]
|
||||
public function publicKey(Request $request): Response
|
||||
{
|
||||
$publicKey = $this->encryptService->getPublicKey();
|
||||
if ($publicKey === '') {
|
||||
return Json::fail('接口加密公钥未配置');
|
||||
}
|
||||
|
||||
return Json::success('获取成功', [
|
||||
'enabled' => $this->encryptService->isEnabled(),
|
||||
'scope' => $this->encryptService->getScope(),
|
||||
'algorithm' => $this->encryptService->getAlgorithm(),
|
||||
'key_version' => $this->encryptService->getKeyVersion(),
|
||||
'public_key' => $publicKey,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user