Files
zyt/server/app/adminapi/controller/IamController.php
T

42 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace app\adminapi\controller;
use app\common\service\iam\IamHubException;
use app\common\service\iam\IamRevocationService;
use think\facade\Log;
class IamController extends BaseAdminController
{
public array $notNeedLogin = ['revocation'];
public function revocation()
{
try {
(new IamRevocationService())->apply(
(string) $this->request->getContent(),
(string) $this->request->header('X-IAM-Signature', ''),
(string) $this->request->header('X-IAM-Event-ID', '')
);
return response('', 204);
} catch (IamHubException $error) {
return json([
'code' => 0,
'show' => 0,
'msg' => $error->getMessage(),
'data' => [],
], $error->httpStatus());
} catch (\Throwable $error) {
Log::error('IAM Hub revocation failed: ' . get_class($error));
return json([
'code' => 0,
'show' => 0,
'msg' => 'IAM Hub revocation failed',
'data' => [],
], 500);
}
}
}