feat(iam): add guarded identity management and ERP launch source

This commit is contained in:
2026-10-29 17:34:55 +08:00
parent bcd42a5c39
commit dcb0db8275
26 changed files with 1827 additions and 5 deletions
@@ -69,6 +69,20 @@ class LoginMiddleware
}
}
// Active requests compensate missed central revocations within a 30-second cache window.
// Local-only unlinked accounts and disabled installations keep their original behavior.
if ($adminInfo && !$isNotNeedLogin && \app\adminapi\service\iam\v2\IamV2Client::enabled()) {
$binding = \think\facade\Db::name('iam_v2_binding')->where('admin_id', $adminInfo['admin_id'])->find();
if ($binding && $binding['state'] !== 'unlinked') {
try {
$b = (new \app\adminapi\service\iam\v2\IamV2Manager())->binding((int) $adminInfo['admin_id']);
if (($b['binding']['state'] ?? '') !== 'verified' || !($b['access']['allowed'] ?? false) || ($b['employee']['status'] ?? '') !== 'active') {
return JsonService::fail('统一账号关联已失效,请重新登录', [], -1);
}
} catch (\Throwable $e) { return JsonService::fail('统一身份服务暂时不可用,请稍后重试', [], 0); }
}
}
//给request赋值,用于控制器
$request->adminInfo = $adminInfo;
$request->adminId = $adminInfo['admin_id'] ?? 0;