revert(iam): 统一登录 - 撤销 IAM Hub 接入

This commit is contained in:
2026-09-08 16:14:59 +08:00
parent 9206d5ea62
commit d0e2422155
860 changed files with 2371 additions and 15106 deletions
@@ -16,11 +16,6 @@ namespace app\adminapi\controller;
use app\adminapi\logic\LoginLogic;
use app\adminapi\validate\LoginValidate;
use app\common\service\iam\IamAdminIdentityService;
use app\common\service\iam\IamExchangeService;
use app\common\service\iam\IamHubException;
use app\common\service\iam\IamOidcService;
use think\facade\Log;
/**
* 管理员登录控制器
@@ -29,57 +24,7 @@ use think\facade\Log;
*/
class LoginController extends BaseAdminController
{
public array $notNeedLogin = [
'account', 'workWechatConfig', 'workWechatLogin', 'checkDbColumn', 'changeFirstPassword',
'iamConfig', 'iamStart', 'iamCallback', 'iamExchange',
];
public function iamConfig()
{
return $this->data([
'enabled' => (new IamOidcService())->enabled(),
]);
}
public function iamStart()
{
try {
return redirect((new IamOidcService())->begin());
} catch (IamHubException $error) {
return json(['code' => 0, 'show' => 1, 'msg' => $error->getMessage(), 'data' => []], $error->httpStatus());
}
}
public function iamCallback()
{
$successUrl = (string) config('iam_hub.login_success_url', '/admin/login');
try {
$code = trim((string) $this->request->get('code', ''));
$state = trim((string) $this->request->get('state', ''));
if ($code === '' || $state === '') {
throw new IamHubException('统一身份登录回调参数缺失');
}
$claims = (new IamOidcService())->callback($code, $state);
$login = (new IamAdminIdentityService())->login($claims, 1);
$exchange = new IamExchangeService((int) config('iam_hub.exchange_ttl_seconds', 60));
$exchangeCode = $exchange->store($login);
return redirect($successUrl . '#iam_code=' . rawurlencode($exchangeCode));
} catch (\Throwable $error) {
Log::error('IAM Hub admin login callback failed: ' . get_class($error));
return redirect($successUrl . '#iam_error=1');
}
}
public function iamExchange()
{
$code = trim((string) $this->request->post('code', ''));
$exchange = new IamExchangeService((int) config('iam_hub.exchange_ttl_seconds', 60));
$login = $exchange->consume($code);
if ($login === null) {
return $this->fail('统一身份登录凭证无效或已过期');
}
return $this->data($login);
}
public array $notNeedLogin = ['account', 'workWechatConfig', 'workWechatLogin', 'checkDbColumn', 'changeFirstPassword'];
/**
* @notes 账号登录
@@ -216,4 +161,4 @@ class LoginController extends BaseAdminController
(new LoginLogic())->logout($this->adminInfo);
return $this->success();
}
}
}