commit c3689d501e191e34fa3c2437b2b7edf043eb7cb6 Author: admin Date: Wed Sep 30 12:01:38 2026 +0800 chore: SSO-only 精简版初始提交(从 ipass-all 派生) **影响**:新建独立仓 ipass-sso 作为 ipass-all 的 SSO-only 精简发行版—— 剔除了 domain / llm / apix / cache / waf 5 个插件及对应的 nginx location 与 LLM/域名数据面 server,PLUGINS 数组只剩 sso + core,单 .so 体积与编 译时间同步下降。镜像名沿用 ssw188/nginx(同 repo 加 tag),新 tag `ipass-sso-v0.6.0`,K8s 部署在 wuguirong ns NodePort 30082,与生产 ipass-all-v0.5.2 (30083/30084/30085) 并存互不干扰。 **改动**: - `rust/Cargo.toml` + `rust/gateway/Cargo.toml`:删 5 个 plugin path 依赖, package/lib 重命名为 `ipass-sso-gateway` / `libipass_sso_gateway` - `rust/gateway/src/lib.rs`:PLUGINS 只剩 `&SsoPlugin` + `&CorePlugin`; GatewayExt 4 个方法改为 no-op / 返回默认值(无 domain/llm 装饰); ModuleConfig 只剩 api + iap 两个开关;NGX_HTTP_COMMANDS 数组 11→4 条; init_process / exit_process 删 llm audit / stats persist 调用; state_zone_init 删 domain/upstreams/apix 的预装载 - `rust/gateway/src/api.rs`:删除(h_admin_trend 依赖 llm + apix) - `deploy/nginx.conf`:删 server 498 (LLM) + server 565 (域名); 主 server 删 `/apix/` `/apixp/` `/_apix_probe/` 等 7 个 location; 删 6 条 `proxy_cache_path` 与 8 个 cache location;删 `ipass_audit_dir` 指令 - `deploy/Dockerfile`:删 5 个 plugin named context 的 COPY 块; .so 文件名改 `libipass_sso_gateway.so` - `deploy/build.sh`:TAG 默认 `ipass-sso-v0.6.0`; 5 个 plugin build-context 删除;删 collect-legacy.sh 调用 - `data-seed/plugin-config.json`:只保留 `sso` 一个 plugin - `scripts/collect-plugin-dist.sh`:PLUGINS 默认值改 `sso` - `scripts/container-entrypoint.sh`:删 cache/audit 目录预创建 - `deploy/legacy/` `tests/` `docs/` `deploy/custom/` `deploy/compose.yml`: 精简版不需要,删除 - `deploy/k8s/ipass-sso.yaml`:新建精简版 K8s manifest (NodePort 30082 单端口;replicas=1;同 10106 准入 + nginx-data PVC sso/ subPath; 探针用 `/admin/` try_files 兜底,与 ipass-all 同款止血方案) **设计**:保留 ipass-core("core 是网关身份底座,永不跳过")+ ipass-plugin-sso, 其余插件整链剥离;不再维护 ssow/ssw 时代的多插件装配文档。剔除 ipass_audit_dir 是因为精简版没有 LLM 对话审计,剔除 proxy_cache_path 同理。K8s 部署沿用 nginx-data PVC + subPath 隔离模式(sso/ 与 ipass-all/ 互不干扰)。 **已知约束**:精简版仍是单进程共享内存,pod 重启使所有管理员/用户会话失效 (与 ipass-all 同款代价)。精简版不带单元/E2E 测试,老管理台 iframe 集成 也未引入。 Co-Authored-By: Claude Code diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54b3476 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# 运行时数据(含口令散列与 Key),绝不入库 +data/ + +# 前端收集产物由 collect-plugin-dist.sh 再生(保留 .gitkeep 目录占位) +deploy/shell/* +!deploy/shell/.gitkeep +deploy/static-plugins/* +!deploy/static-plugins/.gitkeep + +# Rust +rust/target/ + +# 本机调试 +*.log +.DS_Store +.env + +# e2e 运行时产物(cookie/临时 conf/审计/陈旧快照) +tests/.run/ diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..e282db8 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,201 @@ +# CLAUDE.md + +给 AI 协作者的项目说明。本仓是 **ipass-all**:把 iPass 内核与全部插件装配成 +**一个** nginx 动态模块 / **一个**容器 / **一个** K8s Deployment。 + +## 一句话定位 + +iPass 的「全家桶」发行版:`ipass-core`(内核)+ 6 个 crate 级插件 +(sso / domain / llm / apix / cache / waf)+ trend 组合端点,编译期装配进 +单个 `libipass_all_gateway.so`。单进程、零外部依赖(无 DB / Redis / MQ)。 + +**为什么单 .so**:nginx 动态模块无稳定 ABI,多 .so 会撞共享内存 zone tag 冲突 +(启动即 EMERG)与同名变量互相覆盖。论证见 `ipass-sso/docs/plugin-architecture-analysis.md`。 + +## 依赖布局(兄弟仓库,编译期 path 依赖) + +``` +../ipass-core 内核 + vendored ngx-rust(crates.io/git 版 ngx 不可用,见下) +../ipass-plugin-sso 身份:OAuth2/OIDC + IAP(dispatch 排第一,认领身份端点) +../ipass-plugin-domain 动态域名($proxy_backend_addr) +../ipass-plugin-llm LLM 代理($llm_* + 用量统计 + 对话审计) +../ipass-plugin-apix API 代理($apix_* / $apixp_*;依赖 plugin-llm) +../ipass-plugin-cache 制品缓存($cache_*;上游表管理台配,改上游不 reload) +../ipass-plugin-waf WAF(默认 enabled + 内置规则随 .so 分发;vendor/zentinel-modsec 在其仓内) +``` + +⚠️ `ngx` 必须用 `../ipass-core/rust/vendor/ngx-rust`(path 依赖):crates.io 的 +0.5.1 没发请求阶段 API;git 依赖会克隆 nginx 仓库在国内容 networks 永久挂起。 + +## 本机构建(快速检查用) + +```bash +cd rust +export LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib +export NGINX_SOURCE_DIR=$HOME/Desktop/workspace/ipass/ngxbuild/nginx-1.30.4 +export NGINX_BUILD_DIR=$NGINX_SOURCE_DIR/objs +cargo check --release # 或 cargo build --release 出 .dylib +``` + +nginx 源码树不可 `mv`(`objs/Makefile` 里的 `-I` 是绝对路径,挪了要重新 configure)。 + +## 容器构建 / 部署 + +```bash +bash deploy/build.sh # 收集前端 dist → docker build(7 个 named context)→ push +kubectl apply -f deploy/k8s/ipass-all.yaml +``` + +镜像 tag 约定:`crpi-...aliyuncs.com/ssw188/nginx:ipass-all-vX.Y.Z`(只推 ssw188/nginx +这一个 repo,不建新 repo)。**节点 imagePullPolicy=IfNotPresent,新版必须换新 tag。** + +K8s 约束(wuguirong 租户,细节见 Claude 技能 k8s-tenant-wuguirong): +- 容器级 `runAsUser: 10106`(准入强制,pod 级无效);非 root → conf 里 pid/temp 全在 /tmp +- 无新 PVC 可用 → 复用共享 PVC `nginx-data`,subPath `ipass-all/`(initContainer 以 + 10106 预建目录,否则 kubelet 按 root 建目录,业务写盘才炸) +- **replicas 必须 = 1**:运行期真源是进程内共享内存 + JSON 写穿,多副本 = 脑裂 +- 暴露:NodePort 30083(管理台/IdP/apix/cache)+ 30084(LLM) + +## 装配层(rust/gateway/src/lib.rs)要点 + +- `PLUGINS` 数组顺序 = preconfig/postconfig/dispatch 顺序:**SsoPlugin 第一** + (认领 /api/admin|v1 身份端点,带 CAPTCHA/锁定/审计),core 补 sso 没有的端点, + 之后 domain → llm → apix → cache → waf → GatewayRoutes(trend)。 +- 指令集中在 gateway(10 条):main `ipass_state/ipass_data_dir/ipass_audit_dir/ + ipass_stats_persist/ipass_probe_min`;loc `ipass_api/sso_iap/ipass_proxy/ipass_llm/ipass_apix`。 + ⚠️ cache 插件**没有** `ipass_cache` 指令(legacy 独立仓形态才有)——它靠路由前缀 + + R19 总闸生效,conf 里写 `ipass_cache on` 会 unknown directive 启动失败。 +- `state_zone_init` 两层都要:显式装载(domains/users/llm upstreams/apix)+ + 各插件 `zone_load()` 回调(sso 的 OAuth 接入方表靠它)。 +- `GatewayExt` 承 ssw 完整版(decorate_admin_users / decorate_me / reclaim_on_delete + 回收域名 / validate_slots)。llm 的 usage_filter 用 `r->ctx[ctx_index]` 请求槽, + sso 不用请求槽 → 合流无冲突。 +- WAF 默认 `enabled:true` 且规则 `include_str!` 进 .so;误拦时改 + `data/plugin-config.json` 里 `waf.enabled=false` + 重启(改文件需重启,不热生效)。 + +## nginx.conf(deploy/nginx.conf)要点 + +- 端口分工:18098 主(管理台/IdP/API/apix/cache 路由/域名 Host 转发)、18099 LLM + (`//` 首段即 slot,不能挂在带前缀的 location 下)。 +- 管理台静态 location **不开** `ipass_api`;`/_apix_probe//_apixp_probe//_upstream_test/` + 三个 internal 探针必须与 `/api/` 同 server(内部重定向不出 server)。 +- cache location **不写** `ipass_cache`(见上);`proxy_cache_path` 必须 + `use_temp_path=off`(/var/tmp root 属主,10106 写不进)。 +- `ipass_audit_dir` 必须显式指进数据卷(缺省 = data 兄弟目录,不可写)。 +- env 白名单在 main 上下文(sso 的 9 个 env;llm/apix/cache/waf 不读 env)。 + +## 边界 / 常见坑 + +- 改 conf 或 .so 后必须**重启**(reload 不重载动态模块;JSON 是写穿持久化)。 +- **会话在共享内存里**:每次 pod 重启全部管理员/用户会话失效,要重新登录。 +- `KNOWN_PLUGINS`(ipass-core)目前没有 "cache" → 壳菜单不显示制品缓存页, + 插件本身照常工作;要上菜单需给 ipass-core 补登记(上游改动,暂缓)。 +- `plugin-cache` 仓没有 www/(管理页待重写),壳里自然没有它的菜单。 +- 前端壳更新:改完 ipass-core/www 或各插件 www 后重跑 `npm run build` + 本仓 + `scripts/collect-plugin-dist.sh` + 重新构建镜像。 + +## 生产迁移与 TLS(2026-09-26 v0.2.9) + +- **生产数据**(`/Users/xs/Desktop/ipass-88-data`:22 账号 / 5 域名 / 4 LLM 上游 / + 3 API 代理 / 用量快照)已灌入 PVC `ipass-all/`;此前 dev 数据备份在同目录 + `backup-dev-20260926.tar.gz`。⚠️ 直接改 data/*.json 不热生效——**改完必须重启**。 +- **TLS**:证书放**数据目录** `data/tls/`(fullchain.cer / tls.key / ca.cer), + 换证书 = 换文件 + 重启,不重打镜像。证书为多域名证书(SAN 含 + `*.mayishangshu.cn` 等,**2026-11-04 到期**,来源 ipass-ssw/conf/tls)。 +- **端口分工**:30083 = TLS only(SNI:mdm/lm/`*`dm.mayishangshu.cn,路由器 + WAN:188 → 节点 30083,外部入口 `https://mdm.mayishangshu.cn:188`);30085 = + 管理台/域名代理**明文**(内网调试);30084 = LLM 明文。⚠️ nginx 同一端口不能 + 既明文又 TLS(duplicate listen 启动即炸)。⚠️ 容器端口改名后 Service 的 + `targetPort` 必须同步(v0.2.9 实测漏改 → 30083 悬空)。 +- **issuer** = `https://mdm.mayishangshu.cn:188`;`OAUTH_COOKIE_DOMAIN=mayishangshu.cn` + 只影响 sso 终端用户 cookie;admin 会话 cookie 恒为 host-only,IP 直连登录不受影响。 +- 生产域名后端(192.168.1.222:23 / .2:8080 / .22:88 / .15:8787)在本环境**不在线** + → 域名转发 404 属预期,后端上线即通;ssw 测试域名 `i29214898dm → 192.168.1.7:89` + 已并入(.7 同样待开机)。 +- 向数据目录写文件(certs/JSON)可用一次性 busybox Pod 挂 subPath + base64 内嵌 + manifest(`kubectl run -i` 的 stdin 在 overrides 场景不可靠;准入要求 + pod 级 fsGroup=10106 + 容器级 runAsUser=10106)。 + +## 管理台架构定案(2026-09-26,v0.4.0) + +1. **ipass-core 壳只带核心域原生页**:账号管理(`AccountAdmin.vue`,唯一可 + 添加/删除/解锁/Key/密码 的地方,**只管身份与凭据**)+ 插件管理 + (`PluginAdmin.vue`,`POST /api/core/plugins/set` 即时生效 + 落盘)。 + 插件域的用户绑定功能归插件自己:**临时授权**在域名管理(grants.html)、 + **上游白名单/限额**在 LLM 网关(llm-users.html)——core 账号页不再出现这些列。 +2. **装配默认用 core 壳,可整体覆写**:装配仓放 `shell/dist/` 即覆盖默认 + (collect-plugin-dist.sh 已实现);装配自定义页用 `deploy/custom/custom-pages.json` + 清单(group/path/label/url),core 壳 boot 时拉取注册(无此文件静默跳过), + 如 ipass-all 的 数据总览/我的用量。 +3. **插件启用即出顶部菜单**(装载清单驱动);**插件自带左侧菜单**(契约 v2 + `{title, pages}`)。 +4. **与用户绑定的功能,插件可有自己的账号列表/按钮**(如 sso 身份页),但 + **添加/删除/启用等生命周期操作一律跳转 core 账号管理页**(sso.html 已改: + `del-user`/`unlock`/创建表单 → `top.location = /manage/users`)。 +5. 插件页不与 core 页交叉读写——跨域数据靠 API(各插件认领各自路由)。 + +## 管理台壳(2026-09-26 排障定案) + +v0.1.5 修复「/admin/ 打开空白」,根因五个、全在**上游仓**,curl 层全绿只有真浏览器 +才暴露(排障用 agent-browser,注意 intranet 要 `--proxy-bypass`): + +1. 壳无认证接线 → `AppLayout.vue` 401 渲染 `Login.vue`(此前 Login 是死代码); +2. API 信封层级 → 壳读 `data.plugins`,后端回 `{code,data:{plugins}}`,被 `?? []` + 静默吞掉(**登录了也空白**); +3. 面板路由从不注册 → AppLayout 现在 `router.addRoute(panel.routes)`;`/` 路由 + 此前指回 AppLayout 自嵌套 → 改 redirect; +4. 插件 UMD 引用 `process.env.NODE_ENV` → 壳 main.ts 入口 `window.process ??= {env:{}}`; +5. **浏览器原生 `import()` 不做 CJS 互操作**:UMD 包装的 `mod.default` 恒为 + undefined(契约对象落在 `window['ipass-plugin--admin']`)→ loader 按 + `plugin--admin.es.js → plugin--admin.umd.js → -admin.umd.js` + 顺序试,必须拿到 `.default` 才算成功。插件仓一律用 vite **lib 模式** + (formats `['umd','es']`,参考 ipass-plugin-domain/www)出双格式。 + +## 管理台 v0.2 布局与 legacy 集成(2026-09-26 拍板) + +**布局**:顶部横向插件条切面板;多页面板自动出左侧页菜单,单页直显;右上退出登录。 + +**老管理台快速集成**:ssw 九页(git `bf2528d^` 提取)+ sso 五 tab 单页 +(git `9de4d67^`)+ waf.html(工作树)→ `scripts/collect-legacy.sh` 聚合进 +`deploy/legacy/`(sed 改 `base href=/legacy/` + 注入 `#shell{display:none}` 藏老 +导航),Dockerfile 拷到 `www/legacy/`,nginx `/legacy/` 纯静态。老页面 API 与插件 +路由 1:1 兼容、同源同 cookie,`IP.api` 原样工作。iframe 内 401 落 `login.html` +独立兜底。 +⚠️ `deploy/legacy/` 自 2026-09-26 v0.2.6 起是**可维护副本**:collect 脚本只做 +首次引导(目标文件已存在则跳过),人工修改(多选弹窗 / 创建时间列 / https 复制 / +WAF 免 Key 门禁等)不会被构建覆盖;要从上游重提某页,删掉对应文件再跑脚本。 +SPA 直链回退要同时覆盖 `/plugin-` 与 `/manage/` 两个前缀(nginx 缺一个就是 +直链 JSON 404——实测漏过 /manage/)。 + +**契约 v2**(`ipass-core/www/src/loader.ts`):插件 default export +`{ title, pages: [{path, label, url?}] }`——`url` 给了壳就 iframe 原样嵌(老页 +/任意同源页),没给用 `component`。五个插件已全部迁到 v2(各仓 www/src/main.ts +只是清单,面板 UI 全在壳)。壳内置「网关管理」分组(overview/users/me,core 域 +无插件 UMD)。⚠️ 聚合去重:内置路由必须带 `meta.builtin:true` 且 `builtinGroups()` +只认它——插件页面路由同样带 `meta.group`,聚合若把 `getRoutes()` 全算一遍, +每个页面出现两份(实测踩坑)。 + +**新插件接入管理台 = 三步**:插件仓 www 用 lib 模式出 es 产物 + main.ts 写 +`{title, pages}` 清单 + `plugin_registry::KNOWN_PLUGINS` 登记(上游 ipass-core)。 + +## WAF 插件三连坑(2026-09-26,v0.2.3 定案) + +控制台「几乎不可用」的元凶是 WAF 默认 CC 限频误封管理员,连带修了两个上游 bug: + +1. **默认 CC 太紧**:`cc_limit=100 次/60s、ban 600s`——管理台一屏 iframe + 每页 + 十几个 API 全从同一 IP 出,几分钟必触发 `{"code":403,"msg":"cc-ban"}`;且 + **CC 封禁不受 observe 模式豁免**(handler 在 observe 判定之前短路)。 + 现状:`cc_limit=100000`(实际不设限),签名规则仍 observe 记录。 +2. **`waf_conf.json` 只写不读**(上游 bug,已修):`config::store()` 写穿落盘, + 但没人读回 → 重启即回退默认值。修复 = `config::bootstrap_from_disk()` 挂在 + **`WafPlugin::zone_load`**。⚠️ 不能挂 postconfig——那个阶段 shm zone 还没 + 初始化(zone init 在 fork 时才跑),`state::put` 静默无效(v0.2.2 实测踩坑)。 +3. **`cc_limit=0` 假确认**(上游 bug,已修):校验报错文案说「显式传 cc_window>0 + 留档即可」,代码里没有该分支 → CC 永远关不掉。已按文案补上确认逻辑。 + +WAF 管理 API 鉴权用 `sk_` API Key(X-API-Key),**不认管理员会话 cookie**; +读配置用 `GET /api/waf/status`(`/api/waf/config` 只有 PUT)。解封单个 IP: +`DELETE /api/waf/blocks/`;pod 重启也会清 shm 里的 ban。 + +注意:ipass-sso(:30082)镜像里还是旧壳,复现同款空白;要用新壳需按 ipass-sso +仓流程重建镜像重发。 diff --git a/README.md b/README.md new file mode 100644 index 0000000..4dc5ea1 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# ipass-all + +iPass 全插件一体网关:内核 + 6 插件(身份 sso / 域名 domain / LLM 代理 llm / +API 代理 apix / 制品缓存 cache / WAF waf)编译期装配成**单个** nginx 动态模块, +一个容器跑完。单进程、零外部依赖。 + +## 端口 + +| 端口 | 承载 | +|---|---| +| 18098 | 管理台 `/admin/` · OIDC(`/.well-known/openid-configuration`)· `/api/*` · apix(`/apix/`、`/apixp/`)· 制品缓存 8 路由(`/go/ /cargo/ /pypi/ /npm/ /maven/ /v2/…`)· 域名转发(`Host: *.ipass.local`) | +| 18099 | LLM 数据面 `//...`(sk_ Key 鉴权,出站换上游真 Key) | + +## 快速开始 + +```bash +bash deploy/build.sh # 收集前端 + docker build + push 阿里云 CR +kubectl apply -f deploy/k8s/ipass-all.yaml # wuguirong 租户 ns(NodePort 30083/30084) +curl -fs http://192.168.1.26:30083/.well-known/openid-configuration +``` + +首次登录 `admin / 123456`(立即改密)。各插件能力与配置见管理台对应页。 + +## 装配清单与顺序 + +`SsoPlugin → CorePlugin → DomainPlugin → LlmPlugin → ApixPlugin → CachePlugin → WafPlugin → trend` + +顺序即端点认领顺序:sso 排第一接管身份端点;trend 组合端点由装配根自己提供。 + +## 文档 + +- 构建约束、踩坑与边界 → [`CLAUDE.md`](CLAUDE.md) +- K8s 清单 → [`deploy/k8s/ipass-all.yaml`](deploy/k8s/ipass-all.yaml) +- 各插件自身文档 → 兄弟仓 `ipass-plugin-*/CLAUDE.md` diff --git a/data-seed/oauth_clients.json b/data-seed/oauth_clients.json new file mode 100644 index 0000000..04fc8e4 --- /dev/null +++ b/data-seed/oauth_clients.json @@ -0,0 +1,97 @@ +[ + { + "client_id": "grafana", + "client_secret": "cs_grafana_demo_secret_0000000000000000", + "name": "Grafana(演示机密客户端)", + "redirect_uris": [ + "https://grafana.yourdomain.com/login/generic_oauth" + ], + "grant_types": [ + "authorization_code", + "refresh_token" + ], + "scopes": [ + "openid", + "profile", + "email" + ], + "confidential": true, + "created_at": 1768000000 + }, + { + "client_id": "spa-demo", + "client_secret": "", + "name": "单页应用(演示公开客户端,走 PKCE)", + "redirect_uris": [ + "https://app.yourdomain.com/callback" + ], + "grant_types": [ + "authorization_code", + "refresh_token" + ], + "scopes": [ + "openid", + "profile", + "email" + ], + "confidential": false, + "created_at": 1768000000 + }, + { + "client_id": "machine", + "client_secret": "cs_machine_demo_secret_0000000000000000", + "name": "机器对机器(演示 client_credentials / password)", + "redirect_uris": [], + "grant_types": [ + "authorization_code", + "refresh_token", + "client_credentials", + "password" + ], + "scopes": [ + "openid", + "profile", + "email" + ], + "confidential": true, + "created_at": 1768000000 + }, + { + "client_id": "demo-system", + "client_secret": "cs_f5efeab3c50a6332b462561034c55401", + "name": "demo-system 简单业务系统(机密客户端,MaxKey 风格表单传参)", + "redirect_uris": [ + "http://127.0.0.1:18096/oauth2/callback" + ], + "grant_types": [ + "authorization_code", + "refresh_token" + ], + "scopes": [ + "openid", + "profile", + "email" + ], + "confidential": true, + "created_at": 1789000000 + }, + { + "client_id": "demo-spa", + "client_secret": "", + "name": "demo-system 公开客户端(PKCE / S256)", + "redirect_uris": [ + "http://127.0.0.1:18096/oauth2/callback" + ], + "grant_types": [ + "authorization_code", + "refresh_token" + ], + "scopes": [ + "openid", + "profile", + "email" + ], + "confidential": false, + "created_at": 1789000000 + } +] \ No newline at end of file diff --git a/data-seed/plugin-config.json b/data-seed/plugin-config.json new file mode 100644 index 0000000..c4cbff6 --- /dev/null +++ b/data-seed/plugin-config.json @@ -0,0 +1,8 @@ +{ + "plugins": { + "sso": { + "enabled": true, + "admin_prefix": "sso" + } + } +} \ No newline at end of file diff --git a/data-seed/users.json.example b/data-seed/users.json.example new file mode 100644 index 0000000..46c5508 --- /dev/null +++ b/data-seed/users.json.example @@ -0,0 +1,31 @@ +{ + "admin": { + "username": "admin", + "display_name": "管理员", + "role": "admin", + "salt": "", + "pwd_hash": ":') 后迭代 1000 轮 sha256(x + salt)>", + "api_key": "sk_<随机>", + "email": "admin@yourdomain.com", + "department": "平台", + "groups": [ + "admin" + ], + "created_at": 0 + }, + "alice": { + "username": "alice", + "display_name": "爱丽丝", + "role": "user", + "salt": "", + "pwd_hash": ":') 后迭代 1000 轮 sha256(x + salt)>", + "api_key": "sk_<随机>", + "email": "alice@yourdomain.com", + "department": "研发部", + "groups": [ + "rd", + "eng" + ], + "created_at": 0 + } +} diff --git a/deploy/Dockerfile b/deploy/Dockerfile new file mode 100644 index 0000000..37083f5 --- /dev/null +++ b/deploy/Dockerfile @@ -0,0 +1,121 @@ +# ipass-sso 网关镜像 —— 多阶段构建(复用 rust-nginx-base) +# +# 从 ipass-all 派生的精简发行版:只装 ipass-core + ipass-plugin-sso(2 个 named +# context),gateway 装配层把内核 + sso 编进单个 libipass_sso_gateway.so。 +# +# 设计: +# - builder 阶段:FROM crpi-yscq976uwza88qap.cn-shenzhen.personal.cr.aliyuncs.com/ssw188/nginx:1.30.4-rust-1.89 +# base 已含 rust 1.89 + 已 configure/make 的 nginx 1.30.4 + pcre 8.45 + 编译链, +# 这里只跑 cargo build +# - runtime 阶段:debian:bookworm-slim,只带 nginx 二进制 + 模块 + 静态资源 +# +# 构建命令(context = 本仓根;2 个 named context 缺一不可): +# bash scripts/collect-plugin-dist.sh # 前置:收集壳 + sso 管理页 dist +# docker build \ +# --build-context ipass-core=../ipass-core \ +# --build-context ipass-plugin-sso=../ipass-plugin-sso \ +# -t crpi-yscq976uwza88qap.cn-shenzhen.personal.cr.aliyuncs.com/ssw188/nginx:ipass-sso-v0.6.0 . +# +# named context 落位约定:COPY 到 /ipass-core、/ipass-plugin-sso —— builder 的 +# WORKDIR 是 /build,rust/Cargo.toml 里 `../../ipass-core/...` 与插件自己的 +# `../ipass-core/...` 等 path 依赖按宿主机「同级目录」布局原样解析。 +# ⚠️ 每个插件仓只 COPY 编译所需子集(Cargo.toml/src/vendor/rules), +# 避开几百 MB 的 target/ 与 data/。 +# +# 升级 nginx/rust 版本时:先跑 ipass-sso/deploy/build-base-image.sh 推新 base, +# 再 bump 此处 FROM 的 tag。 + +# syntax=docker/dockerfile:1.7 + +ARG BASE_TAG=1.30.4-rust-1.89 + +# =========================================================================== +# builder: 复用 rust-nginx-base + Rust 模块编译(nginx 二进制 base 里已 make 好) +# =========================================================================== +FROM crpi-yscq976uwza88qap.cn-shenzhen.personal.cr.aliyuncs.com/ssw188/nginx:${BASE_TAG} AS builder + +WORKDIR /build + +# 内核(含 vendored ngx-rust 与 pcre 路径依赖的源码树约定) +COPY --from=ipass-core /rust/Cargo.toml /rust/Cargo.lock /ipass-core/rust/ +COPY --from=ipass-core /rust/crates/ /ipass-core/rust/crates/ +COPY --from=ipass-core /rust/vendor/ /ipass-core/rust/vendor/ + +# SSO 插件 crate(只 1 个 plugin) +COPY --from=ipass-plugin-sso /Cargo.toml /Cargo.lock /ipass-plugin-sso/ +COPY --from=ipass-plugin-sso /src/ /ipass-plugin-sso/src/ + +# 装配层(本仓) +COPY rust/ /build/rust/ + +# cargo 国内镜像源(rsproxy):base 镜像没带 cargo 配置,直连 crates.io +# 在国内网络下会长时间悬挂在下载阶段(ipass-sso 同款)。 +RUN printf '[source.crates-io]\nreplace-with = "rsproxy-sparse"\n\n[source.rsproxy-sparse]\nregistry = "sparse+https://rsproxy.cn/index/"\n\n[net]\ngit-fetch-with-cli = true\n' \ + > "${CARGO_HOME:-/usr/local/cargo}/config.toml" + +WORKDIR /build/rust +# nginx 源码树路径与 base 镜像内一致(bindgen 从 objs/Makefile 抽 -I) +ENV NGINX_SOURCE_DIR=/src/nginx-1.30.4 +ENV NGINX_BUILD_DIR=/src/nginx-1.30.4/objs +ENV CARGO_TARGET_DIR=/build/rust/target + +RUN cargo build --release 2>&1 | tail -15 + +# =========================================================================== +# runtime: 极简镜像,只带 nginx 二进制 + 模块 + 静态资源 + 种子数据 +# =========================================================================== +FROM debian:bookworm-slim AS runtime + +ARG NGINX_VERSION=1.30.4 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + libpcre2-8-0 \ + zlib1g \ + libssl3 \ + ca-certificates \ + curl \ + tzdata \ + python3 \ + && rm -rf /var/lib/apt/lists/* + +# 与 iPass 一致:TZ=Asia/Shanghai,util::day_id 按上海时区 0:00 切日(趋势/用量口径) +ENV TZ=Asia/Shanghai + +COPY --from=builder /src/nginx-${NGINX_VERSION}/objs/nginx /usr/local/nginx/sbin/nginx +COPY --from=builder /src/nginx-${NGINX_VERSION}/conf/mime.types /usr/local/nginx/conf/mime.types +COPY --from=builder /build/rust/target/release/libipass_sso_gateway.so /usr/local/nginx/modules/ + +# 生产配置(deploy/nginx.conf:全插件 location 布局 + 非 root 适配) +COPY deploy/nginx.conf /usr/local/nginx/conf/nginx.conf + +# 管理台前端(Ruling 16):构建前由 scripts/collect-plugin-dist.sh 把 +# ipass-core 壳收集进 deploy/shell、各插件 dist 收集进 deploy/static-plugins +COPY deploy/shell/ /usr/local/nginx/www/ +COPY deploy/static-plugins/ /usr/local/nginx/static-plugins/ +# 装配层自定义页清单(core 壳 boot 时拉取并注册为自定义页;其他装配可没有) +COPY deploy/custom/ /usr/local/nginx/static-custom/ +# 老管理台多页应用(collect-legacy.sh 从各仓提取,壳内 iframe 原样集成) +COPY deploy/legacy/ /usr/local/nginx/www/legacy/ + +# 种子数据(admin/alice + OAuth 接入方 + 插件启停注册表) +COPY data-seed/ /usr/local/nginx/data-seed/ + +# 目录与属主:k8s 租户准入强制 runAsUser=10106,data 与 /tmp/nginx 必须 +# 预先可写(挂 PVC 后属主由 fsGroup=10106 接管,chown 只保无卷直跑)。 +# 日志走 /dev/std* 符号链接(kubectl logs 直接可见)。 +RUN mkdir -p /usr/local/nginx/data /usr/local/nginx/logs /tmp/nginx \ + && chown -R 10106:10106 /usr/local/nginx/data /tmp/nginx \ + && ln -sf /dev/stdout /usr/local/nginx/logs/access.log \ + && ln -sf /dev/stderr /usr/local/nginx/logs/error.log + +# 首次启动播种 admin/alice + 渲染配置 + 起 nginx +COPY scripts/container-entrypoint.sh /usr/local/nginx/scripts/container-entrypoint.sh +COPY scripts/seed-data.sh /usr/local/nginx/scripts/seed-data.sh +RUN chmod +x /usr/local/nginx/scripts/container-entrypoint.sh /usr/local/nginx/scripts/seed-data.sh + +WORKDIR /usr/local/nginx +EXPOSE 18098 18099 +STOPSIGNAL SIGQUIT + +ENTRYPOINT ["/usr/local/nginx/scripts/container-entrypoint.sh"] +CMD ["nginx", "-g", "daemon off;"] diff --git a/deploy/build.sh b/deploy/build.sh new file mode 100644 index 0000000..8b29c76 --- /dev/null +++ b/deploy/build.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# ============================================================================ +# build.sh —— 构建 + 推送 ipass-sso 镜像(可选手动 docker 命令见 Dockerfile 头注释) +# +# 从 ipass-all 派生的精简版,只装配 ipass-core + ipass-plugin-sso(2 个 named +# context)。与 ipass-all/deploy/build.sh 同款外壳,去掉 5 个非 SSO 插件的 +# build-context。 +# +# 用法: +# bash deploy/build.sh # 收集 dist → docker build → push +# bash deploy/build.sh --no-push # 只构建 +# bash deploy/build.sh --load # 构建后 load 进本地 docker(默认行为) +# TAG=ipass-sso-v0.6.0 bash deploy/build.sh +# +# 镜像仓库约定(2026-09-26 拍板):只推 crpi-.../ssw188/nginx 这一个 repo 路径, +# tag 用 -vX.Y.Z;同 repo 加 tag 零成本,不要建新 repo。 +# ============================================================================ +set -euo pipefail + +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(cd "$HERE/.." && pwd)" +IPASS_DIR="$(cd "$ROOT/.." && pwd)" + +REGISTRY="${REGISTRY:-crpi-yscq976uwza88qap.cn-shenzhen.personal.cr.aliyuncs.com}" +REPO="${REPO:-ssw188/nginx}" +TAG="${TAG:-ipass-sso-v0.6.0}" +IMAGE="$REGISTRY/$REPO:$TAG" + +PUSH=1 +NO_PUSH=0 +for arg in "$@"; do + case "$arg" in + --no-push) NO_PUSH=1 ;; + esac +done + +echo "== 1/2 收集前端产物(壳 + sso 管理页)==" +bash "$ROOT/scripts/collect-plugin-dist.sh" + +echo "== 2/2 docker build:$IMAGE ==" +cd "$ROOT" +docker build \ + --build-context "ipass-core=$IPASS_DIR/ipass-core" \ + --build-context "ipass-plugin-sso=$IPASS_DIR/ipass-plugin-sso" \ + -f "$HERE/Dockerfile" \ + -t "$IMAGE" \ + . + +if [ "$NO_PUSH" = "1" ]; then + echo "== 跳过 push(--no-push)==" +else + echo "== docker push:$IMAGE ==" + docker push "$IMAGE" +fi + +echo "完成:$IMAGE" \ No newline at end of file diff --git a/deploy/k8s/ipass-sso.yaml b/deploy/k8s/ipass-sso.yaml new file mode 100644 index 0000000..1e4990e --- /dev/null +++ b/deploy/k8s/ipass-sso.yaml @@ -0,0 +1,128 @@ +# ============================================================================ +# ipass-sso K8s 部署清单(wuguirong 租户 ns)—— SSO-only 精简版 +# +# 集群约束(与 ipass-all 同源,2026-09-26 摸底结论): +# - 准入 tenant-storage-guard:容器级 securityContext.runAsUser=10106(pod 级无效) +# - SC nfs-wuguirong 的 provisioner CrashLoopBackOff,新 PVC 供给不了 +# → 复用已 Bound 共享 PVC nginx-data,subPath sso/ 隔离数据 +# - 无 Ingress → NodePort:30082(TLS only,单端口;精简版没有 LLM/域名数据面) +# - 无 secrets 权限 → 密钥类配置明文 env(与 docker-compose 同水平) +# +# 硬约束:replicas=1。运行期真源是进程内共享内存 + JSON 写穿, +# 多副本各自持 shm 互不可见(脑裂),架构上不允许横向扩。 +# +# 应用:kubectl apply -f deploy/k8s/ipass-sso.yaml +# 验证:curl -fs http://192.168.1.26:30082/.well-known/openid-configuration +# ============================================================================ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ipass-sso + namespace: wuguirong + labels: + app: ipass-sso +spec: + replicas: 1 + strategy: + type: Recreate # 共享 PVC RWX 但数据语义单写:滚动时新旧并存会双写 JSON + selector: + matchLabels: + app: ipass-sso + template: + metadata: + labels: + app: ipass-sso + spec: + securityContext: + runAsUser: 10106 + runAsNonRoot: true + fsGroup: 10106 + # 数据子目录 bootstrap:subPath 目录必须预先存在且属主 10106 + # (kubelet 对不存在的 subPath 按 root 属主建,10106 写不进——挂载成功 + # 之后业务写盘才炸,最难查)。幂等,每次滚动都会跑。 + initContainers: + - name: init-data-dir + image: crpi-yscq976uwza88qap.cn-shenzhen.personal.cr.aliyuncs.com/ssw188/nginx:ipass-sso-v0.6.0 + imagePullPolicy: IfNotPresent + command: ["bash", "-c", "mkdir -p /persist/sso && ls -la /persist"] + securityContext: + runAsUser: 10106 + runAsNonRoot: true + allowPrivilegeEscalation: false + volumeMounts: + - name: data + mountPath: /persist + containers: + - name: ipass-sso + image: crpi-yscq976uwza88qap.cn-shenzhen.personal.cr.aliyuncs.com/ssw188/nginx:ipass-sso-v0.6.0 + imagePullPolicy: IfNotPresent + ports: + - name: tls + containerPort: 18098 # TLS:NodePort 30082 + env: + # issuer 必须与浏览器/第三方实际访问地址逐字一致 + - name: OAUTH_ISSUER + value: "https://192.168.1.26:30082" + # SSO cookie 域(共享 cookie 给同根域名) + - name: OAUTH_COOKIE_DOMAIN + value: "mayishangshu.cn" + # 固定签名密钥:不设则 seed 随机生成,Pod 重启后已签发 token 全部失效 + - name: OAUTH_SIGNING_SECRET + value: "ipass-sso-k8s-dev-signing-key-2026" + securityContext: + runAsUser: 10106 + runAsNonRoot: true + allowPrivilegeEscalation: false + capabilities: + drop: ["ALL"] + resources: + requests: + cpu: 100m + memory: 128Mi + limits: + cpu: "1" + memory: 512Mi + readinessProbe: + httpGet: + scheme: HTTPS + # /admin/ 走 nginx 原生 try_files 兜底到 SPA index.html(与 ipass-all 同款止血方案) + path: /admin/ + port: 18098 + initialDelaySeconds: 5 + periodSeconds: 10 + livenessProbe: + httpGet: + scheme: HTTPS + path: /admin/ + port: 18098 + initialDelaySeconds: 10 + periodSeconds: 20 + failureThreshold: 3 + volumeMounts: + - name: data + mountPath: /usr/local/nginx/data + subPath: sso + volumes: + # 复用已 Bound 的共享 PVC(nfs-wuguirong SC,新建 PVC 供给不了); + # sso 数据经 subPath 隔离在 sso/ 子目录,与 ipass-all/ 互不干扰 + - name: data + persistentVolumeClaim: + claimName: nginx-data + +--- +apiVersion: v1 +kind: Service +metadata: + name: ipass-sso + namespace: wuguirong + labels: + app: ipass-sso +spec: + type: NodePort + selector: + app: ipass-sso + ports: + - name: tls + port: 18098 + targetPort: tls + nodePort: 30082 \ No newline at end of file diff --git a/deploy/nginx.conf b/deploy/nginx.conf new file mode 100644 index 0000000..b912392 --- /dev/null +++ b/deploy/nginx.conf @@ -0,0 +1,151 @@ +# ============================================================================ +# ipass-sso 容器运行配置(精简版:身份/IdP + 管理台) +# +# 从 ipass-all/deploy/nginx.conf 派生的 SSO-only 版(2026-09-30 拍板): +# 剔除了 domain / llm / apix / cache / waf 5 个插件对应的 location 与 +# 整个 LLM 数据面 server、动态域名 server;只保留身份 / 管理台 / API 端点。 +# +# 指令清单 = 本仓 gateway 注册的 4 条: +# main : ipass_state / ipass_data_dir +# loc : ipass_api / sso_iap +# +# 非 root 适配(k8s 租户准入强制 runAsUser=10106): +# pid/lock/temp 全部挪 /tmp +# ============================================================================ + +worker_processes auto; +error_log /usr/local/nginx/logs/error.log info; +pid /tmp/nginx/nginx.pid; +lock_file /tmp/nginx/nginx.lock; + +load_module /usr/local/nginx/modules/libipass_sso_gateway.so; + +# 模块读取的 env 白名单(nginx 默认剥离全部环境变量;漏一条 = worker 里恒空) +env ADMIN_INIT_PASSWORD; +env OAUTH_SIGNING_SECRET; +env OAUTH_ISSUER; +env OAUTH_COOKIE_DOMAIN; +env SYNC_DINGTALK_URL; +env SYNC_WORKWECHAT_URL; +env SYNC_FEISHU_URL; +env PASSWORD_RESET_TOKEN_SINK; +env PASSWORD_RESET_TTL; + +events { + worker_connections 2048; +} + +http { + include /usr/local/nginx/conf/mime.types; + default_type application/json; # 业务侧默认 JSON,静态页在对应 location 覆盖 + sendfile on; + keepalive_timeout 65; + + # ------------------------------------------------------------------ + # 非 root 适配:临时目录默认在编译前缀下(root 属主),10106 建不了 + # ------------------------------------------------------------------ + client_body_temp_path /tmp/nginx/client_body; + proxy_temp_path /tmp/nginx/proxy; + fastcgi_temp_path /tmp/nginx/fastcgi; + + # ------------------------------------------------------------------ + # 日志:带身份维度(WAF/缓存/域名等插件字段在精简版省略),排障不翻模块日志 + # ------------------------------------------------------------------ + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" "$http_user_agent" ' + '"$upstream_addr" "$upstream_status" "$upstream_response_time" ' + 'auth_user=$auth_user'; + access_log /usr/local/nginx/logs/access.log main; + + # ------------------------------------------------------------------ + # 内核:共享内存 + 数据目录(必须显式,理由见文件头) + # ------------------------------------------------------------------ + ipass_state state 16m; # 身份会话+账号 Key(精简版无域名/用量/缓存/WAF) + ipass_data_dir /usr/local/nginx/data; + + # ================================================================== + # 主 server(NodePort 30082):管理台 + IdP 全部端点 + # ================================================================== + # 证书:多域名证书(SAN 含 *.mayishangshu.cn / mayishangshu.cn 等, + # 2026-11-04 到期);证书放**数据目录**(PVC:/usr/local/nginx/data/tls/), + # 换证书 = 换文件 + 重启,不用重打镜像。 + # ⚠️ nginx 同一端口不能既明文又 TLS:18098 = TLS only(NodePort 30082); + # 明文入口 = 18097(同端口)。 + ssl_certificate /usr/local/nginx/data/tls/fullchain.cer; + ssl_certificate_key /usr/local/nginx/data/tls/tls.key; + ssl_trusted_certificate /usr/local/nginx/data/tls/ca.cer; + ssl_protocols TLSv1.2 TLSv1.3; + + server { + listen 18098 ssl default_server; # TLS + listen 18097; # 明文(内网调试) + server_name _; + + absolute_redirect off; + port_in_redirect off; + + # 管理台核心壳(ipass-core www dist)+ sso 管理页 + root /usr/local/nginx/www; + index index.html; + + client_max_body_size 10m; + client_body_buffer_size 1m; + + # ---- 管理/身份 API(content 阶段读体后按 PLUGINS 顺序分发)---- + # 认领方:sso(身份端点/OIDC/SCIM/CAS/门户)+ core(账号/插件启停注册表) + location /api/ { + ipass_api on; + } + + # OIDC/身份协议端点挂在根路径(/oauth/* /login /logout /userinfo + # /.well-known/* /apps /reset /cas/*),由 sso 插件认领 + location / { + ipass_api on; + } + + # ---- 管理台静态资源(这些 location 不开 ipass_api:静态文件走 nginx)---- + location = / { + return 302 /admin/; + } + location = /admin { + return 302 /admin/; + } + location = /index.html { + add_header Cache-Control "no-store" always; + } + location /admin/ { + try_files $uri $uri/ /index.html; # SPA history 深链兜底 + add_header Cache-Control "no-store" always; + } + # 插件面板路由(/plugin-)走壳 SPA:直链/刷新时回 index.html + location /plugin- { + try_files $uri /index.html; + add_header Cache-Control "no-store" always; + } + # 壳内置面板路由(/manage/*,网关管理三页)同上 + location /manage/ { + try_files $uri /index.html; + add_header Cache-Control "no-store" always; + } + location /assets/ { + add_header Cache-Control "no-store" always; + } + + # 插件管理页 UMD 产物(壳按 /static/plugins//dist/-admin.umd.js 拉取) + location /static/plugins/ { + alias /usr/local/nginx/static-plugins/; + add_header Cache-Control "no-store" always; + } + # 装配层自定义页清单(壳 boot 时拉取 /static/custom/custom-pages.json 注册自定义页) + location /static/custom/ { + alias /usr/local/nginx/static-custom/; + add_header Cache-Control "no-store" always; + } + + # 老管理台多页应用(壳内 iframe 原样集成;纯静态,不开 ipass_api) + location /legacy/ { + alias /usr/local/nginx/www/legacy/; + add_header Cache-Control "no-store" always; + } + } +} \ No newline at end of file diff --git a/deploy/shell/.gitkeep b/deploy/shell/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/deploy/static-plugins/.gitkeep b/deploy/static-plugins/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/rust/Cargo.lock b/rust/Cargo.lock new file mode 100644 index 0000000..0da5325 --- /dev/null +++ b/rust/Cargo.lock @@ -0,0 +1,2182 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c880a97d28a3681c0267bd29cff89621202715b065127cd445fa0f0fe0aa2880" + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags 2.13.2", + "cexpr", + "clang-sys", + "itertools", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex 1.3.0", + "syn 2.0.119", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f360145194ee8e21db5ee7f3fcd4fe52210864c75c985dae33218202c8bbe040" +dependencies = [ + "find-msvc-tools", + "shlex 2.0.1", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clang-sys" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "either" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" + +[[package]] +name = "encoding_rs" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "h2" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "html-escape" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9356095b4b41197bba32173600e1582792cda618f65d12f68e2e77d273413c5" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "humantime" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15cdd26707701c53297e2fa6afb323d55fbc1d0810c3aec078ae3ef0424c3c15" + +[[package]] +name = "hyper" +version = "0.14.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.5.10", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" + +[[package]] +name = "icu_properties" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" + +[[package]] +name = "icu_provider" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipass-all-gateway" +version = "1.0.0" +dependencies = [ + "ipass-core", + "ipass-plugin-apix", + "ipass-plugin-cache", + "ipass-plugin-domain", + "ipass-plugin-llm", + "ipass-plugin-sso", + "ipass-plugin-waf", + "nginx-sys", + "ngx", + "serde", + "serde_json", +] + +[[package]] +name = "ipass-core" +version = "2.0.0" +dependencies = [ + "getrandom 0.2.17", + "libc", + "nginx-sys", + "ngx", + "serde", + "serde_json", + "sha2", +] + +[[package]] +name = "ipass-plugin-apix" +version = "2.0.0" +dependencies = [ + "ipass-core", + "ipass-plugin-llm", + "nginx-sys", + "ngx", + "serde", + "serde_json", +] + +[[package]] +name = "ipass-plugin-cache" +version = "2.0.0" +dependencies = [ + "ipass-core", + "nginx-sys", + "ngx", + "serde", + "serde_json", +] + +[[package]] +name = "ipass-plugin-domain" +version = "2.0.0" +dependencies = [ + "ipass-core", + "nginx-sys", + "ngx", + "serde", + "serde_json", +] + +[[package]] +name = "ipass-plugin-llm" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "chrono", + "env_logger", + "ipass-core", + "log", + "nginx-sys", + "ngx", + "reqwest", + "serde", + "serde_json", + "tokio", + "uuid", +] + +[[package]] +name = "ipass-plugin-sso" +version = "2.0.0" +dependencies = [ + "ipass-core", + "nginx-sys", + "ngx", + "serde", + "serde_json", + "sha2", +] + +[[package]] +name = "ipass-plugin-waf" +version = "0.1.0" +dependencies = [ + "ipass-core", + "ipnetwork", + "libc", + "nginx-sys", + "ngx", + "once_cell", + "serde", + "serde_json", + "thiserror", + "zentinel-modsec", +] + +[[package]] +name = "ipnet" +version = "2.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" + +[[package]] +name = "ipnetwork" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf370abdafd54d13e54a620e8c3e1145f28e46cc9d704bc6d94414559df41763" + +[[package]] +name = "is-terminal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.189" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mio" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b18443e9c262bfe8fa82f51666e2642c53393f7e5c27b3e1aeab922cff5b9d8" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nginx-sys" +version = "0.5.0" +dependencies = [ + "bindgen", + "cc", + "dunce", + "errno", + "regex", + "shlex 2.0.1", +] + +[[package]] +name = "ngx" +version = "0.5.0" +dependencies = [ + "allocator-api2", + "lock_api", + "nginx-sys", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "openssl" +version = "0.10.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "foreign-types", + "libc", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "phf" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" +dependencies = [ + "phf_macros", + "phf_shared", + "serde", +] + +[[package]] +name = "phf_generator" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" +dependencies = [ + "fastrand", + "phf_shared", +] + +[[package]] +name = "phf_macros" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "phf_shared" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.119", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "winreg", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags 2.13.2", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "serde_json" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e" + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "tinystr" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.6.5", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "libc", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-ident" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef6dac1e96601b4fb3acccccff2139741fcb757cb9a36089bf5be91cfb285ce" +dependencies = [ + "getrandom 0.4.3", + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.6", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33811428bee40dbceb6d545e95754741d17a6aef9a4849f0fd62e2ba4f412a78" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", + "synstructure", +] + +[[package]] +name = "zentinel-modsec" +version = "0.4.0" +dependencies = [ + "aho-corasick", + "base64 0.22.1", + "glob", + "hex", + "html-escape", + "ipnetwork", + "md-5", + "once_cell", + "percent-encoding", + "phf", + "quick-xml", + "regex", + "regex-syntax", + "serde", + "serde_json", + "sha1", + "sha2", + "thiserror", + "tracing", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..a1d68d6 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,43 @@ +# ipass-sso —— iPass SSO-only 精简版网关 Cargo workspace +# +# 从 ipass-all 派生的精简发行版:只装 ipass-core + ipass-plugin-sso, +# 编译期装配进单个 cdylib .so。剔除的插件(domain / llm / apix / +# cache / waf)不在依赖里也不在编译路径上,PLUGINS 数组只剩 sso + core。 +# +# ipass-core 内核(账号 / Key / 会话 / 共享内存原语 / plugin 契约) +# ipass-plugin-sso 身份:OAuth2/OIDC + IAP(认领身份端点,排最前) +# +# ⚠️ 依赖必须用 vendored 源码(../ipass-core/rust/vendor/ngx-rust),不能走 +# crates.io(请求阶段 API 未发版)也不能走 git(submodule 克隆 nginx 仓库 +# 国内网络永久挂起)。 +# +# 路径全部相对本文件(rust/)的上一级:宿主机与容器内都按 +# 「ipass-sso/rust 与各兄弟仓同级」布局落位(容器内由 Dockerfile named +# context 把兄弟仓 COPY 到 /ipass-core、/ipass-plugin-sso)。 +[workspace] +resolver = "2" +members = ["gateway"] +exclude = ["target"] + +[workspace.package] +version = "1.0.0" +edition = "2021" +publish = false + +[workspace.dependencies] +ngx = { path = "../../ipass-core/rust/vendor/ngx-rust" } +nginx-sys = { path = "../../ipass-core/rust/vendor/ngx-rust/nginx-sys" } +ipass-core = { path = "../../ipass-core/rust/crates/ipass-core" } +ipass-plugin-sso = { path = "../../ipass-plugin-sso" } + +# 业务层依赖:全部是纯 Rust 实现,不引入任何系统库或常驻依赖 +serde = { version = "1", features = ["derive"] } +serde_json = "1" + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 +# 模块被加载进 nginx 这个 C 进程,panic 绝不能跨 FFI 边界展开 +panic = "abort" +strip = true diff --git a/rust/gateway/Cargo.toml b/rust/gateway/Cargo.toml new file mode 100644 index 0000000..14eaa41 --- /dev/null +++ b/rust/gateway/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "ipass-sso-gateway" +version.workspace = true +edition.workspace = true +publish.workspace = true +description = "iPass SSO-only 精简版网关装配层 —— module 壳 + sso+core 插件注册表,产出 nginx 动态模块" + +[lib] +# cdylib:给 nginx load_module 加载 +name = "ipass_sso_gateway" +crate-type = ["cdylib"] + +[features] +default = ["export-modules"] +# 脱离 nginx 构建系统、单独产出动态模块时必须开启(生成 ngx_modules 表) +export-modules = [] + +[dependencies] +ngx.workspace = true +nginx-sys.workspace = true +ipass-core.workspace = true +ipass-plugin-sso.workspace = true + +serde.workspace = true +serde_json.workspace = true diff --git a/rust/gateway/build.rs b/rust/gateway/build.rs new file mode 100644 index 0000000..bc4930b --- /dev/null +++ b/rust/gateway/build.rs @@ -0,0 +1,20 @@ +//! 构建脚本:让 cdylib 允许「未定义符号」。 +//! +//! nginx 动态模块的运行时符号(`ngx_palloc` / `ngx_http_add_variable` / +//! `ngx_shared_memory_add` …)由 nginx 主程序在 `load_module` 时提供, +//! 链接本模块时它们必然是未定义的——这是动态模块的固有属性,不是错误。 +//! +//! * Linux:cdylib 默认允许未定义符号,无需处理。 +//! * macOS:必须显式 `-undefined dynamic_lookup`,否则 ld 直接报 +//! `symbol(s) not found for architecture x86_64`。 +//! +//! 注意:vendored 的 `ngx` crate 的 build.rs 也设了这两项,但 +//! `rustc-link-arg` 只对「设置它的那个 crate」生效,不会传递给依赖它的 +//! crate,所以本 crate 必须自己再设一次。 + +fn main() { + if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") { + println!("cargo::rustc-link-arg=-undefined"); + println!("cargo::rustc-link-arg=dynamic_lookup"); + } +} diff --git a/rust/gateway/src/lib.rs b/rust/gateway/src/lib.rs new file mode 100644 index 0000000..2465842 --- /dev/null +++ b/rust/gateway/src/lib.rs @@ -0,0 +1,457 @@ +//! # ipass-sso —— iPass SSO-only 精简版网关装配层 +//! +//! 从 ipass-all 派生的精简发行版:只装 ipass-core + ipass-plugin-sso, +//! 编进单个 .so。剔除的插件(domain / llm / apix / cache / waf)不在 +//! 依赖里也不在编译路径上。 +//! +//! ```text +//! load_module modules/libipass_sso_gateway.so; +//! │ +//! ipass-core sso +//! (内核) (身份) +//! ``` +//! +//! ## 装配顺序(显式可控) +//! +//! `PLUGINS` 数组的顺序就是 preconfig → postconfig → dispatch_api 的顺序, +//! dispatch 按顺序认领、先注册者先得。 +//! +//! **SsoPlugin 排第一**:两侧重叠的身份端点(login/logout/session/users +//! CRUD/me)由 sso 优先接管——它带 CAPTCHA、账号锁定、审计与身份字段; +//! CorePlugin 只补 sso 没有的端点。 + +// 内核模块桥接:本 crate 用 ipass_core 的 users::seed_admin 播种管理员 +pub use ipass_core::{config, http, state, store, users, util}; + +use core::ffi::{c_char, c_void}; +use core::ptr; + +use ngx::core::{NGX_CONF_ERROR, NGX_CONF_OK, NgxStr, NgxString, SlabPool, Status}; +use ngx::ffi::{ + NGX_CONF_TAKE1, NGX_CONF_TAKE2, NGX_HTTP_LOC_CONF, NGX_HTTP_LOC_CONF_OFFSET, + NGX_HTTP_MAIN_CONF, NGX_HTTP_MAIN_CONF_OFFSET, NGX_HTTP_MODULE, NGX_LOG_EMERG, + ngx_command_t, ngx_conf_t, ngx_cycle_t, ngx_http_module_t, ngx_http_request_t, + ngx_int_t, ngx_module_t, ngx_parse_size, ngx_shared_memory_add, ngx_shm_zone_t, + ngx_str_t, ngx_uint_t, +}; +use ngx::http::{ + HTTPStatus, HttpModule, HttpModuleLocationConf, HttpPhase, HttpRequestHandler, Merge, + MergeConfigError, Request, +}; +use ngx::{ngx_conf_log_error, ngx_string}; +use serde_json::Value; + +use ipass_core::loc::{self, Switch}; +use ipass_core::plugin::Plugin; +use ipass_plugin_sso::SsoPlugin; + +// =========================================================================== +// 插件装配(PLUGINS 顺序 = 认领顺序;身份端点必须排最前) +// =========================================================================== + +/// 插件注册表。**身份类端点(SsoPlugin)排最前**:dispatch 按顺序认领, +/// 先注册者先得。精简版只装 sso + core。 +static PLUGINS: &[&dyn Plugin] = &[ + &SsoPlugin, + &ipass_core::api::CorePlugin, +]; + +/// 装配根的插件扩展:把身份端点需要的插件侧数据回填给内核 +/// (内核不认识任何插件,见 `ipass_core::api::CoreExt`)。 +/// 精简版不挂任何插件侧数据:sso 的身份数据随账号本表删除,无附加回收项; +/// 无域名/LLM 用量装饰(domain/llm/apix 插件不在装配内)。 +struct GatewayExt; + +impl ipass_core::api::CoreExt for GatewayExt { + /// 管理台账号列表:精简版无 domain/llm 装饰。 + fn decorate_admin_users(&self, _views: &mut [Value]) { + // SSO 精简版:账号只带身份字段,不挂域名数 / 用量摘要 + } + + /// `/api/v1/me`:精简版只回基础字段。 + fn decorate_me( + &self, + _user: &ipass_core::models::User, + _port: &str, + _view: &mut Value, + ) { + // SSO 精简版:不挂域名 / 用量 / 能力目录 + } + + /// 删除账号:sso 的身份数据随账号本表删除,无附加回收项。 + fn reclaim_on_delete(&self, _username: &str) -> usize { + 0 + } + + /// 账号「可用上游」白名单校验:精简版无 LLM 上游表,不校验。 + fn validate_slots(&self, _slots: &[String]) -> Result<(), String> { + Ok(()) + } +} + +// =========================================================================== +// 管理 API 分发(壳统一收口) +// =========================================================================== + +/// 管理 API 分发:按 PLUGINS 顺序问每个插件,都不认领才统一 404。 +fn dispatch_api(r: *mut ngx_http_request_t) -> Status { + for p in PLUGINS { + // R19:被禁插件不认领路由(自然落到下面的统一 404)。 + // core 是网关身份底座,永不跳过。 + if p.name() != "core" && !ipass_core::plugin_registry::plugin_enabled(p.name()) { + continue; + } + if let Some(s) = p.dispatch_api(r) { + return s; + } + } + let method = http::method_str(r); + let uri = http::uri(r); + http::fail( + r, + HTTPStatus::NOT_FOUND, + &format!("接口不存在:{method} {uri}"), + ) +} + +/// 管理 API:content 阶段先读请求体,读完后分发。 +/// +/// 精简版只有 sso + core 两个插件处理 API,没有 GatewayRoutes 组合端点。 +struct ApiHandler; + +impl HttpRequestHandler for ApiHandler { + const PHASE: HttpPhase = HttpPhase::Content; + type Output = Status; + + fn handler(request: &mut Request) -> Self::Output { + if !Module::location_conf(request).map(|c| c.api).unwrap_or(false) { + return Status::NGX_DECLINED; + } + + let r: *mut ngx_http_request_t = request.as_mut() as *mut ngx_http_request_t; + + // SAFETY: r 有效;回调只会在请求内存池存活期间被调用 + let rc = unsafe { nginx_sys::ngx_http_read_client_request_body(r, Some(api_body_ready)) }; + + // 读体失败(请求体超限等):把原始状态码交回 nginx,由它生成对应错误页 + if rc >= nginx_sys::NGX_HTTP_SPECIAL_RESPONSE as ngx_int_t { + return Status(rc); + } + + // 响应由回调发出,本阶段到此挂起 + Status::NGX_DONE + } +} + +/// 请求体就绪回调:执行路由分发并终结请求。 +unsafe extern "C" fn api_body_ready(r: *mut ngx_http_request_t) { + let status = dispatch_api(r); + // SAFETY: r 由 nginx 传入且仍然有效;NGX_OK 表示响应已完整发出 + unsafe { nginx_sys::ngx_http_finalize_request(r, status.0) }; +} + +// =========================================================================== +// 模块定义 +// =========================================================================== + +struct Module; + +/// 按 location 生效的开关。精简版只暴露 api + iap 两个开关。 +#[derive(Debug, Default)] +struct ModuleConfig { + /// 该 location 暴露管理 API + 身份协议端点(`/api/*`、`/oauth/*`、`/login`) + api: bool, + /// 该 location 开启身份感知代理(IAP):未登录 → 跳转登录 / 401, + /// 已登录 → 注入 `$auth_*` 变量由 `proxy_set_header` 转成 `X-Auth-*` 头。 + iap: bool, +} + +unsafe impl HttpModuleLocationConf for Module { + type LocationConf = ModuleConfig; +} + +impl Merge for ModuleConfig { + fn merge(&mut self, prev: &ModuleConfig) -> Result<(), MergeConfigError> { + if prev.api { + self.api = true; + } + if prev.iap { + self.iap = true; + } + Ok(()) + } +} + +/// 把本模块的 location 开关暴露给内核,插件据此判断自己是否生效。 +/// 未实现的变体(Domain/Proxy/Llm/Apix)**保守返回 false**,绝不误开。 +fn loc_switch(request: &mut Request, s: Switch) -> bool { + let conf = Module::location_conf(request); + match s { + Switch::Api => conf.map(|c| c.api).unwrap_or(false), + Switch::Iap => conf.map(|c| c.iap).unwrap_or(false), + Switch::Domain | Switch::Proxy | Switch::Llm | Switch::Apix => false, + } +} + +impl HttpModule for Module { + fn module() -> &'static ngx_module_t { + // SAFETY: 模块定义是静态的,生命周期贯穿进程 + unsafe { &*ptr::addr_of!(ngx_http_ipass_sso_module) } + } + + /// 必须在配置解析前注册变量 + unsafe extern "C" fn preconfiguration(cf: *mut ngx_conf_t) -> ngx_int_t { + // 契约层:注入 location 开关查询实现(早于任何请求与 phase handler) + loc::set_switch_fn(loc_switch); + // 装配根注册插件扩展:身份端点所需的插件侧数据经它回填内核 + ipass_core::api::set_ext(&GatewayExt); + + // 各插件注册自己的 nginx 变量($auth_* 归 sso) + for p in PLUGINS { + if !p.preconfig(cf) { + ngx_conf_log_error!( + NGX_LOG_EMERG, + unsafe { &mut *cf }, + "插件 {} 变量注册失败", + p.name() + ); + return Status::NGX_ERROR.into(); + } + } + + Status::NGX_OK.into() + } + + unsafe extern "C" fn postconfiguration(cf: *mut ngx_conf_t) -> ngx_int_t { + let cf = unsafe { &mut *cf }; + + // R19:装载插件启停注册表 + let cfg = ipass_core::plugin_registry::load(&format!( + "{}/plugin-config.json", + store::data_dir() + )); + ipass_core::plugin_registry::set_current(cfg); + + // 把本模块 ctx_index 注入内核契约 + ipass_core::plugin::set_ctx_index(Module::module().ctx_index as usize); + + // 各插件注册自己的 phase handler(IAP 门禁归 sso) + for p in PLUGINS { + if !p.postconfig(cf) { + ngx_conf_log_error!( + NGX_LOG_EMERG, + cf, + "插件 {} 注册阶段处理器失败", + p.name() + ); + return Status::NGX_ERROR.into(); + } + } + + // 管理接口由壳统一收口,内部按插件顺序分发 + if ngx::http::add_phase_handler::(cf).is_err() { + return Status::NGX_ERROR.into(); + } + Status::NGX_OK.into() + } +} + +// 精简版只装 sso + core:4 条指令 +static mut NGX_HTTP_IPASS_SSO_COMMANDS: [ngx_command_t; 5] = [ + ngx_command_t { + name: ngx_string!("ipass_state"), + type_: (NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE2) as ngx_uint_t, + set: Some(set_state_zone), + conf: NGX_HTTP_MAIN_CONF_OFFSET, + offset: 0, + post: ptr::null_mut(), + }, + ngx_command_t { + name: ngx_string!("ipass_data_dir"), + type_: (NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE1) as ngx_uint_t, + set: Some(set_data_dir), + conf: NGX_HTTP_MAIN_CONF_OFFSET, + offset: 0, + post: ptr::null_mut(), + }, + ngx_command_t { + name: ngx_string!("ipass_api"), + type_: (NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1) as ngx_uint_t, + set: Some(set_flag_api), + conf: NGX_HTTP_LOC_CONF_OFFSET, + offset: 0, + post: ptr::null_mut(), + }, + ngx_command_t { + name: ngx_string!("sso_iap"), + type_: (NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1) as ngx_uint_t, + set: Some(set_flag_iap), + conf: NGX_HTTP_LOC_CONF_OFFSET, + offset: 0, + post: ptr::null_mut(), + }, + ngx_command_t::empty(), +]; + +static NGX_HTTP_IPASS_SSO_MODULE_CTX: ngx_http_module_t = ngx_http_module_t { + preconfiguration: Some(Module::preconfiguration), + postconfiguration: Some(Module::postconfiguration), + create_main_conf: None, + init_main_conf: None, + create_srv_conf: None, + merge_srv_conf: None, + create_loc_conf: Some(Module::create_loc_conf), + merge_loc_conf: Some(Module::merge_loc_conf), +}; + +// 脱离 nginx 构建系统、单独产出 cdylib 时必须靠这个宏导出 ngx_modules 表 +#[cfg(feature = "export-modules")] +ngx::ngx_modules!(ngx_http_ipass_sso_module); + +#[used] +#[allow(non_upper_case_globals)] +pub static mut ngx_http_ipass_sso_module: ngx_module_t = ngx_module_t { + ctx: &raw const NGX_HTTP_IPASS_SSO_MODULE_CTX as _, + commands: unsafe { &raw mut NGX_HTTP_IPASS_SSO_COMMANDS[0] }, + type_: NGX_HTTP_MODULE as _, + init_process: Some(init_process), + exit_process: Some(exit_process), + ..ngx_module_t::default() +}; + +/// 每个 worker 启动后执行一次。管理员播种是**幂等**的。 +unsafe extern "C" fn init_process(_cycle: *mut ngx_cycle_t) -> ngx_int_t { + match users::seed_admin() { + Ok(true) => util::log_warn( + "[ipass] 已创建初始管理员 admin,请首次登录后立即修改密码", + ), + Ok(false) => {} + Err(e) => util::log_err(&format!("[ipass] 初始化管理员失败: {e}")), + } + Status::NGX_OK.into() +} + +/// worker 退出前执行一次。精简版无运行期统计要落盘,钩子留空即可。 +unsafe extern "C" fn exit_process(_cycle: *mut ngx_cycle_t) { + // SSO 精简版:共享内存里只有身份会话与账号 Key,重启即失效属已知代价, + // 不需要 exit 钩子落盘。 +} + +// =========================================================================== +// 指令处理 +// =========================================================================== + +/// 读第 2 个参数并转成 bool(on/off/1/0/yes/no)。 +unsafe fn arg_flag(cf: *mut ngx_conf_t, idx: usize) -> Option { + let cf_ref = unsafe { cf.as_mut() }?; + let args: &mut [ngx_str_t] = unsafe { (*cf_ref.args).as_slice_mut() }; + let raw = args.get(idx)?.as_bytes(); + let s = core::str::from_utf8(raw).ok()?; + Some(matches!(s.to_ascii_lowercase().as_str(), "on" | "1" | "true" | "yes")) +} + +extern "C" fn set_flag_api( + cf: *mut ngx_conf_t, + _cmd: *mut ngx_command_t, + conf: *mut c_void, +) -> *mut c_char { + let Some(flag) = (unsafe { arg_flag(cf, 1) }) else { + return NGX_CONF_ERROR; + }; + // SAFETY: nginx 保证 conf 指向本模块的 loc conf 结构 + unsafe { (*(conf as *mut ModuleConfig)).api = flag }; + NGX_CONF_OK +} + +extern "C" fn set_flag_iap( + cf: *mut ngx_conf_t, + _cmd: *mut ngx_command_t, + conf: *mut c_void, +) -> *mut c_char { + let Some(flag) = (unsafe { arg_flag(cf, 1) }) else { + return NGX_CONF_ERROR; + }; + // SAFETY: 同上 + unsafe { (*(conf as *mut ModuleConfig)).iap = flag }; + NGX_CONF_OK +} + +extern "C" fn set_state_zone( + cf: *mut ngx_conf_t, + _cmd: *mut ngx_command_t, + _conf: *mut c_void, +) -> *mut c_char { + // SAFETY: 配置回调必然拿到有效的 cf + let cf_ref = unsafe { cf.as_mut().unwrap() }; + let args: &mut [ngx_str_t] = unsafe { (*cf_ref.args).as_slice_mut() }; + + let mut name: ngx_str_t = args[1]; + let size = unsafe { ngx_parse_size(&raw mut args[2]) }; + if size == -1 { + ngx_conf_log_error!(NGX_LOG_EMERG, cf_ref, "ipass_state: 共享内存大小非法"); + return NGX_CONF_ERROR; + } + + let zone = unsafe { + ngx_shared_memory_add( + cf, + &raw mut name, + size as usize, + (&raw mut ngx_http_ipass_sso_module).cast(), + ) + }; + if zone.is_null() { + return NGX_CONF_ERROR; + } + + unsafe { + (*zone).init = Some(state_zone_init); + } + state::set_zone(zone); + NGX_CONF_OK +} + +/// 共享内存初始化:由 nginx 在 **fork 之前**调用一次。 +/// +/// 精简版只装载 sso 自持表(OAuth 接入方表由 SsoPlugin::zone_load 自己装)+ +/// 各插件 zone_load 回调;无 domain/llm/apix 数据面需要预装载。 +extern "C" fn state_zone_init(zone: *mut ngx_shm_zone_t, _data: *mut c_void) -> ngx_int_t { + let status = state::init_zone(zone); + if status != Status::NGX_OK { + return status.into(); + } + + // 各插件自持表的预装载(sso 的 OAuth 接入方等); + // 没有自持表的插件返回 0,仅打日志。 + for p in PLUGINS { + let n = p.zone_load(); + util::log_notice(&format!("[gateway] 插件 {} 预装载 {n} 条", p.name())); + } + + Status::NGX_OK.into() +} + +extern "C" fn set_data_dir( + cf: *mut ngx_conf_t, + _cmd: *mut ngx_command_t, + _conf: *mut c_void, +) -> *mut c_char { + // SAFETY: 配置回调必然拿到有效的 cf + let cf_ref = unsafe { cf.as_mut().unwrap() }; + let args: &mut [ngx_str_t] = unsafe { (*cf_ref.args).as_slice_mut() }; + + match core::str::from_utf8(args[1].as_bytes()) { + Ok(dir) => { + store::set_data_dir(dir); + NGX_CONF_OK + } + Err(_) => { + ngx_conf_log_error!(NGX_LOG_EMERG, cf_ref, "ipass_data_dir: 路径不是合法 UTF-8"); + NGX_CONF_ERROR + } + } +} + +/// 供测试与诊断使用:`NgxStr` 类型在模块里被多处引用,确保编译期链接到正确的符号 +#[allow(dead_code)] +fn _type_witness(_: &NgxStr, _: &NgxString) {} \ No newline at end of file diff --git a/scripts/collect-plugin-dist.sh b/scripts/collect-plugin-dist.sh new file mode 100644 index 0000000..ba6dae7 --- /dev/null +++ b/scripts/collect-plugin-dist.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +# ============================================================================ +# collect-plugin-dist.sh —— 收集管理台前端产物到可部署目录 +# +# 形状与 ipass-sso / ipass-ssw 的同名脚本一致(Ruling 16/19): +# - 核心壳来自 ipass-core/www/dist(SPA:index.html + assets) +# - 插件管理页是 UMD 产物,壳按 /static/plugins//dist/-admin.umd.js +# 动态加载(寻址约定见 ipass-core www loader.ts; = Plugin::name() 短名) +# +# Docker 构建上下文只覆盖本仓,COPY 不到兄弟仓库,故先把产物聚合进 +# deploy/,再由 Dockerfile COPY 进镜像。 +# +# 输出布局: +# deploy/shell/ ← ../ipass-core/www/dist +# deploy/static-plugins//dist/ ← ../ipass-plugin-/www/dist +# +# 插件清单 = 本仓装配的全部插件(精简版只装 sso;其他插件仓不存在时自动跳过并告警)。 +# 用法:bash scripts/collect-plugin-dist.sh # → deploy/ +# ============================================================================ +set -euo pipefail + +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(cd "$HERE/.." && pwd)" +IPASS_DIR="${IPASS_DIR:-$(cd "$ROOT/.." && pwd)}" +ASSEMBLY_DIR="${ASSEMBLY_DIR:-deploy}" + +case "$ASSEMBLY_DIR" in + /*) OUT="$ASSEMBLY_DIR" ;; + *) OUT="$ROOT/$ASSEMBLY_DIR" ;; +esac + +SHELL_SUB="${SHELL_SUB:-shell}" +PLUGINS_SUB="${PLUGINS_SUB:-static-plugins}" + +# 本仓 gateway 装配的插件短名(顺序无关;缺 dist 自动跳过并告警) +PLUGINS="${PLUGINS:-sso}" + +# --------------------------------------------------------------------------- +# 1) 核心壳(默认 ipass-core www dist;**装配仓可用自己的 shell/dist 覆写**—— +# 2026-09-26 架构定案第 2 条:各装配默认用 core 框架,也可整体重写壳) +# --------------------------------------------------------------------------- +SHELL_SRC="$IPASS_DIR/ipass-core/www/dist" +if [ -d "$ROOT/shell/dist" ] && [ -f "$ROOT/shell/dist/index.html" ]; then + SHELL_SRC="$ROOT/shell/dist" + echo "装配仓自带壳,覆盖 core 默认:$SHELL_SRC" +fi +SHELL_OUT="$OUT/$SHELL_SUB" +[ -d "$SHELL_SRC" ] || { echo "!! core shell dist 缺失:$SHELL_SRC(先在 ipass-core/www 跑 npm run build)" >&2; exit 1; } +mkdir -p "$SHELL_OUT" +rsync -a --delete --exclude .gitkeep "$SHELL_SRC/" "$SHELL_OUT/" +echo "shell : $SHELL_SRC → $SHELL_OUT" + +# --------------------------------------------------------------------------- +# 2) 各插件的管理页 dist +# --------------------------------------------------------------------------- +PLUGINS_OUT="$OUT/$PLUGINS_SUB" +mkdir -p "$PLUGINS_OUT" +# 清空旧收集产物但保留 .gitkeep(Dockerfile COPY 依赖目录存在) +find "$PLUGINS_OUT" -mindepth 1 -maxdepth 1 ! -name .gitkeep -exec rm -rf {} + + +count=0 +for short in $PLUGINS; do + src="$IPASS_DIR/ipass-plugin-${short}/www/dist" + if [ ! -d "$src" ]; then + echo "!! ${short}:$src 缺失(先在 ipass-plugin-${short}/www 跑 npm run build),跳过" >&2 + continue + fi + mkdir -p "$PLUGINS_OUT/$short/dist" + rsync -a --delete "$src/" "$PLUGINS_OUT/$short/dist/" + # 产物原文件名是 plugin-<短名>-admin.umd.js;壳按短名请求 + # /static/plugins/<短名>/dist/<短名>-admin.umd.js → 补一份短名别名 + if [ ! -f "$PLUGINS_OUT/$short/dist/${short}-admin.umd.js" ] \ + && [ -f "$PLUGINS_OUT/$short/dist/plugin-${short}-admin.umd.js" ]; then + cp "$PLUGINS_OUT/$short/dist/plugin-${short}-admin.umd.js" \ + "$PLUGINS_OUT/$short/dist/${short}-admin.umd.js" + fi + echo "plugin: $src → $PLUGINS_OUT/$short/dist" + count=$((count + 1)) +done + +echo "完成:shell + ${count} 个插件 → $OUT" diff --git a/scripts/container-entrypoint.sh b/scripts/container-entrypoint.sh new file mode 100755 index 0000000..254733f --- /dev/null +++ b/scripts/container-entrypoint.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +# ============================================================================ +# 容器入口脚本(首发 + 每次启动都跑) +# +# 干的事: +# 1. 首次启动:data/ 为空时跑 seed-data.sh,生成 admin/123456 + alice/alice123 +# 2. 每次启动:把容器外的 env(OAUTH_ISSUER 等)打印出来供排障 +# 3. nginx -t 语法预检 +# 4. exec nginx(让 nginx 拿到 PID 1,否则 stop signal 收不到) +# +# 设计: +# - nginx.test.conf 用了 env 占位(OAUTH_ISSUER / OAUTH_SIGNING_SECRET 等), +# nginx 启动时会从环境变量读取,无需重新渲染模板 +# - seed-data.sh 用 python3 算 SHA-256 散列(与 rust/src/util.rs::hash_password +# 逐位一致:sha256("salt:password") 后迭代 1000 轮 sha256(x + salt)) +# ============================================================================ +set -euo pipefail + +DATA_DIR="/usr/local/nginx/data" +SEED_DIR="/usr/local/nginx/data-seed" +NGINX_CONF="/usr/local/nginx/conf/nginx.conf" +LOG_DIR="/usr/local/nginx/logs" + +c_ok() { printf '\033[32m✓\033[0m %s\n' "$*"; } +c_warn() { printf '\033[33m!\033[0m %s\n' "$*"; } +c_err() { printf '\033[31m✗\033[0m %s\n' "$*" >&2; } + +# ---------------------------------------------------------------- 0. 基础目录 +mkdir -p "$DATA_DIR" "$LOG_DIR" + +# ---------------------------------------------------------------- 1. 打印关键 env(排障) +printf '\n== ipass-sso 启动参数 ==\n' +c_ok "OAUTH_ISSUER = ${OAUTH_ISSUER:-<未设置,默认走 nginx.conf 占位>}" +c_ok "OAUTH_COOKIE_DOMAIN= ${OAUTH_COOKIE_DOMAIN:-<未设置>}" +c_ok "ADMIN_USER = ${ADMIN_USER:-admin}" +if [ -n "${ADMIN_PASSWORD:-}" ]; then + c_ok "ADMIN_PASSWORD = <已注入>" +else + c_warn "ADMIN_PASSWORD = <未注入>,seed 将使用默认 123456" +fi +if [ -n "${OAUTH_SIGNING_SECRET:-}" ]; then + c_ok "OAUTH_SIGNING_SECRET= <已注入>" +else + c_warn "OAUTH_SIGNING_SECRET= <未注入>,seed 将生成随机值(重启即丢!)" +fi + +# ---------------------------------------------------------------- 2. 数据物化(首次启动) +NEED_SEED=0 +[ ! -f "$DATA_DIR/users.json" ] && NEED_SEED=1 +[ ! -f "$DATA_DIR/oauth_clients.json" ] && NEED_SEED=1 + +if [ "$NEED_SEED" = "1" ]; then + printf '\n== 首次启动:seed-data.sh 物化 admin/alice ==\n' + # nginx worker 是 nobody(uid 65534),必须可写 + chown -R 65534:65534 "$DATA_DIR" 2>/dev/null || c_warn "chown 65534 失败(继续)" + + ADMIN_PASSWORD="${ADMIN_PASSWORD:-123456}" \ + ALICE_PASSWORD="${ALICE_PASSWORD:-alice123}" \ + DATA_DIR="$DATA_DIR" \ + SEED_DIR="$SEED_DIR" \ + bash /usr/local/nginx/scripts/seed-data.sh || \ + { c_err "seed-data.sh 失败"; exit 1; } + c_ok "data 目录物化完成" +else + c_ok "data 目录已有,跳过 seed" +fi + +# ---------------------------------------------------------------- 3. nginx 语法预检 +printf '\n== nginx -t ==\n' +/usr/local/nginx/sbin/nginx -t -c "$NGINX_CONF" 2>&1 || { c_err "nginx 配置语法错误"; exit 1; } + +# ---------------------------------------------------------------- 4. exec nginx(PID 1 拿信号) +printf '\n== 起 nginx ==\n' +exec /usr/local/nginx/sbin/nginx -c "$NGINX_CONF" -g 'daemon off;' diff --git a/scripts/push-init.sh b/scripts/push-init.sh new file mode 100755 index 0000000..386911c --- /dev/null +++ b/scripts/push-init.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +# push-init.sh —— 读取 ~/.ssw.ini [credential-git-18] 建仓(Gitea API)并推送 ipass-all +# 密钥只在脚本进程内流转,任何输出过滤掉口令字面量 +set -euo pipefail + +INI="$HOME/ssw.ini" +HOST="192.168.1.18:13300" +ORG="ipass" +REPO="ipass-all" + +read_ini() { # read_ini + awk -F= -v sec="credential-git-18" -v key="$1" ' + /^\[/ { f = ($0 ~ "\\[" sec "\\]") ? 1 : 0; next } + f && $1 ~ key { gsub(/\r/, "", $2); gsub(/^ +| +$/, "", $2); print $2; exit } + ' "$INI" +} + +U="$(read_ini username)" +P="$(read_ini password)" +[ -n "$U" ] && [ -n "$P" ] || { echo "FAIL: ini 解析不到凭证"; exit 1; } + +sanitized() { # 吞掉可能夹带的口令字面量 + grep -v "$P" | head -c 300 +} + +# 1) 若仓库已存在则跳过建仓 +CODE=$(curl -s -o /tmp/repo-check.json -w '%{http_code}' -u "$U:$P" "http://$HOST/api/v1/repos/$ORG/$REPO") +if [ "$CODE" = "200" ]; then + echo "仓库已存在: $ORG/$REPO" +else + echo "建仓 org/$REPO …" + RES=$(curl -s -u "$U:$P" -X POST "http://$HOST/api/v1/org/$ORG/repos" \ + -H 'Content-Type: application/json' \ + -d '{"name":"ipass-all","private":true,"auto_init":false,"description":"iPass 全插件一体网关(内核+6插件单.so单容器)"}') + if echo "$RES" | grep -q '"full_name"'; then + echo "建仓 OK" + else + echo "org 域建仓失败,尝试用户域 …" + RES=$(curl -s -u "$U:$P" -X POST "http://$HOST/api/v1/user/repos" \ + -H 'Content-Type: application/json' \ + -d '{"name":"ipass-all","private":true,"auto_init":false}') + if echo "$RES" | grep -q '"full_name"'; then + ORG="$U" + echo "建仓 OK(用户域: $U/$REPO)" + else + echo "FAIL: 建仓被拒"; echo "$RES" | sanitized; exit 1 + fi + fi +fi + +# 2) 挂远端(干净 URL,凭证走一次性 credential helper,不写入 .git/config) +cd "$(dirname "$0")" +git remote remove origin 2>/dev/null || true +git remote add origin "http://$HOST/$ORG/$REPO.git" + +echo "推送 main …" +if git \ + -c credential.helper= \ + -c "credential.helper=!f(){ printf 'username=%s\n' '$U'; printf 'password=%s\n' '$P'; }; f" \ + push -u origin main 2>&1 | sanitized | tail -3; then + echo "PUSH OK: $ORG/$REPO (main)" +else + echo "PUSH FAIL(上方为过滤后输出)" + exit 1 +fi diff --git a/scripts/seed-data.sh b/scripts/seed-data.sh new file mode 100755 index 0000000..4070219 --- /dev/null +++ b/scripts/seed-data.sh @@ -0,0 +1,171 @@ +#!/usr/bin/env bash +# ============================================================================ +# 物化运行时数据目录:data-seed/ -> data/ +# +# 为什么需要这一步 +# data/ 是**运行时**目录(可写、含真实口令散列),不进版本库; +# data-seed/ 是**种子模板**(只放演示客户端与示例账号),进版本库。 +# 本脚本把两者接起来,并顺便把示例里的占位符换成真实值。 +# +# 做的事: +# 1. data/oauth_clients.json <- data-seed/oauth_clients.json +# 2. data/users.json <- 由本脚本生成(admin / alice 两个账号) +# 3. data/users.json.example <- 同步一份示例(占位符,不含真实散列) +# +# 幂等:users.json 已存在时**默认不动**(避免覆盖你手工改过的账号),要重建加 --force。 +# +# 用法: +# bash scripts/seed-data.sh # 缺什么补什么 +# bash scripts/seed-data.sh --force # 重建 users.json(会丢已有账号) +# DATA_DIR=/path ADMIN_PASSWORD=xxx bash scripts/seed-data.sh +# +# 口令来源:ADMIN_PASSWORD(默认 123456)、ALICE_PASSWORD(默认 alice123)。 +# 这两个默认值只用于**本机/CI 演示**,生产部署必须覆盖。 +# ============================================================================ +set -euo pipefail + +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(cd "$HERE/.." && pwd)" +SEED_DIR="${SEED_DIR:-$ROOT/data-seed}" +DATA_DIR="${DATA_DIR:-$ROOT/data}" + +ADMIN_PASSWORD="${ADMIN_PASSWORD:-123456}" +ALICE_PASSWORD="${ALICE_PASSWORD:-alice123}" + +FORCE=0 +for a in "$@"; do [ "$a" = "--force" ] && FORCE=1; done + +PYTHON="${PYTHON:-python3}" + +[ -d "$SEED_DIR" ] || { echo "!! 种子目录缺失:$SEED_DIR" >&2; exit 1; } +mkdir -p "$DATA_DIR" + +# --------------------------------------------------------------------------- +# 1. OAuth 接入方注册表:直接拷贝(没有则视为空表) +# --------------------------------------------------------------------------- +if [ -f "$SEED_DIR/oauth_clients.json" ]; then + if [ ! -f "$DATA_DIR/oauth_clients.json" ] || [ "$FORCE" = "1" ]; then + cp "$SEED_DIR/oauth_clients.json" "$DATA_DIR/oauth_clients.json" + echo " [seed] oauth_clients.json 已写入 $DATA_DIR/oauth_clients.json" + else + echo " [seed] oauth_clients.json 已存在,跳过" + fi +else + echo " [seed] 警告:$SEED_DIR/oauth_clients.json 不存在,注册表留空" +fi + +# --------------------------------------------------------------------------- +# 1.5 插件启停注册表(R19):拷种子(缺省语义是「未列出 = 启用」,但显式 +# 注册表让管理台/运维一眼看清装配了哪些插件,禁用也只改这一个文件) +# --------------------------------------------------------------------------- +if [ -f "$SEED_DIR/plugin-config.json" ]; then + if [ ! -f "$DATA_DIR/plugin-config.json" ] || [ "$FORCE" = "1" ]; then + cp "$SEED_DIR/plugin-config.json" "$DATA_DIR/plugin-config.json" + echo " [seed] plugin-config.json 已写入 $DATA_DIR/plugin-config.json" + else + echo " [seed] plugin-config.json 已存在,跳过" + fi +fi + +# --------------------------------------------------------------------------- +# 2. 账号表:生成真实散列。 +# +# ⚠️ 散列算法必须与 rust/src/util.rs::hash_password 逐位一致, +# 否则生成的账号永远登录不上: +# x = sha256("salt:password") ← 注意中间是冒号 +# 重复 HASH_ROUNDS(=1000,见 config.rs) 次:x = sha256(x + salt) +# 改了拼接顺序或轮数,存量 users.json 会全部失效。 +# --------------------------------------------------------------------------- +if [ -f "$DATA_DIR/users.json" ] && [ "$FORCE" != "1" ]; then + echo " [seed] users.json 已存在,跳过(要重建加 --force)" +else + ADMIN_PASSWORD="$ADMIN_PASSWORD" ALICE_PASSWORD="$ALICE_PASSWORD" \ + OUT="$DATA_DIR/users.json" USERS_EXAMPLE="$SEED_DIR/users.json.example" \ + "$PYTHON" - <<'PYEOF' +import hashlib, json, os, secrets + +HASH_ROUNDS = 1000 # 必须与 rust/src/config.rs 的 HASH_ROUNDS 一致 + +def pwd_hash(salt, password): + x = hashlib.sha256(("%s:%s" % (salt, password)).encode()).hexdigest() + for _ in range(HASH_ROUNDS): + x = hashlib.sha256((x + salt).encode()).hexdigest() + return x + +def entry(username, display_name, password, role, email, department, groups, + api_key, created_at=1768000000): + salt = secrets.token_hex(16) # 32 位 hex + return { + "username": username, + "display_name": display_name, + "role": role, + "salt": salt, + "pwd_hash": pwd_hash(salt, password), + "api_key": api_key, + "email": email, + "department": department, + "groups": groups, + "created_at": created_at, + } + +users = { + "admin": entry( + "admin", "管理员", os.environ["ADMIN_PASSWORD"], "admin", + "admin@yourdomain.com", "平台", ["admin"], + "sk_" + secrets.token_hex(20), + ), + "alice": entry( + "alice", "爱丽丝", os.environ["ALICE_PASSWORD"], "user", + "alice@yourdomain.com", "研发部", ["rd", "eng"], + "sk_" + secrets.token_hex(20), + ), +} + +out = os.environ["OUT"] +with open(out, "w", encoding="utf-8") as f: + json.dump(users, f, ensure_ascii=False, indent=2) + f.write("\n") + +# 同步一份「占位符版」示例回种子目录,让后来人一眼看懂字段含义 +HASH_NOTE = "sha256(':') 后迭代 1000 轮 sha256(x + salt)" +example = { + "admin": { + "username": "admin", + "display_name": "管理员", + "role": "admin", + "salt": "", + "pwd_hash": "<%s>" % HASH_NOTE, + "api_key": "sk_<随机>", + "email": "admin@yourdomain.com", + "department": "平台", + "groups": ["admin"], + "created_at": 0, + }, + "alice": { + "username": "alice", + "display_name": "爱丽丝", + "role": "user", + "salt": "", + "pwd_hash": "<%s>" % HASH_NOTE, + "api_key": "sk_<随机>", + "email": "alice@yourdomain.com", + "department": "研发部", + "groups": ["rd", "eng"], + "created_at": 0, + }, +} +# 回写占位符示例只对「仓库内 host 流程」有意义(容器里种子目录在只读镜像层, +# 写不进也不该写——10106 非 root 跑会在这里 PermissionError 打断整个 seed) +example_path = os.environ["USERS_EXAMPLE"] +if os.access(example_path, os.W_OK): + with open(example_path, "w", encoding="utf-8") as f: + json.dump(example, f, ensure_ascii=False, indent=2) + f.write("\n") +else: + print(" [seed] 种子目录不可写(容器镜像层),跳过示例回写:%s" % example_path) + +print(" [seed] users.json 已生成 %s(admin + alice)" % out) +PYEOF +fi + +echo " [seed] 数据目录就绪:$DATA_DIR"