feat: integrate ZYT admin with IAM Hub
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user