Files
sso/source/rust/Cargo.toml
T
ssw a988cc3763 refactor: 网关拆分为 ipass-core 内核 + plugin-sso/plugin-domain 插件 + gateway
原 source/rust/src/ 单体 crate 拆为 Cargo workspace:

  crates/ipass-core/    内核:state(共享内存) / store(JSON 原子写) /
                        users(账号唯一写入口) / models(共性字段 + extra 透传) /
                        config(共性常量) / plugin(装配契约) / loc(开关) /
                        session / audit / http / util
  crates/plugin-sso/    身份插件:OAuth2 / OIDC / IAP / TOTP / RSA 等个性代码
  crates/plugin-domain/ 域名插件:企业域名「子域名 → 后端」转发 + 申请/审核
  gateway/              **唯一** cdylib,module 壳 + PLUGINS 装配数组

收窄原则:内核只留共性,个性代码下放插件。收窄后内核不再提供原单体的
bump_window / put_ukey / put_upstream / reload_shm 等,改由插件用 state 泛型
原语自行重建;OAuth 常量与前缀(如 OAUTH_SESSION_COOKIE=sso_sid、
IAP_TOKEN_AUDIENCE=sso-gateway)与历史取值严格一致。

插件一律 crate-type=["rlib"] 由 gateway 静态链入,产出单个
libsso_gateway.dylib —— 不各自出 .so(nginx 动态模块无稳定 ABI,
跨 .so 传 String 即双重 free)。

插件装配点集中在 gateway 5 处:use / PLUGINS 数组 / ModuleConfig 字段 /
Merge / loc_switch 分支,外加指令数组(长度 +1,新增 sso_domain 等开关)。
2026-09-13 10:23:34 +08:00

60 lines
2.9 KiB
TOML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# iPass 统一网关 —— Cargo workspace
#
# 结构:
# crates/ipass-core 网关内核:共享内存状态、users.json 的唯一读写者、账号与 Key
# crates/plugin-sso 身份插件:OAuth2/OIDC 签发与校验、IAP 身份注入
# crates/plugin-domain 域名插件:内核之上「新增一个能力插件」的完整示例
# gateway 装配层:module 壳 + 插件注册表 → 产出单个 .so
#
# 为什么是「单 .so + crate 级插件」而不是「多 .so 运行时插件」:
# nginx 动态模块没有稳定 ABI,Rust 侧更是如此(每个 cdylib 各链一份 std)。
# 跨 .so 共享状态要自己造 C ABI 契约,且 zone tag / 同名变量都会冲突
# (详见 docs/plugin-architecture-analysis.md)。
#
# ⚠️ vendor/ngx-rust 本身是 workspace 根,必须 exclude,否则 cargo 报歧义。
[workspace]
members = ["crates/ipass-core", "crates/plugin-sso", "crates/plugin-domain", "gateway"]
exclude = ["vendor/ngx-rust"]
[workspace.package]
version = "1.0.0"
edition = "2021"
publish = false
# ---------------------------------------------------------------------------
# ⚠️ 依赖必须用 vendored 源码,不能走 crates.io,也不能走 git:
#
# 1) `ngx = "0.5"`(crates.io 0.5.1)只发布了配置阶段接口(HttpModule),
# 请求阶段 API(add_phase_handler / HttpPhase / HttpRequestHandler)尚未发版,
# 实测直接编译失败:unresolved imports `ngx::http::HttpPhase`
#
# 2) git 依赖会永久挂起:ngx-rust 挂了一个指向完整 nginx 仓库的 submodule
# [submodule "nginx-src/nginx"] url = https://github.com/nginx/nginx.git
# cargo 解析 git 依赖时会 update_submodules,去克隆几十 MB 的 nginx 仓库,
# 国内网络下卡死(实测 cargo 5 分钟 0% CPU,调用栈停在
# GitSource::block_until_ready -> GitCheckout::update_submodules -> fetch -> wait4)。
#
# 因此 vendor 到 vendor/ngx-rust/,用 path 依赖:离线可编译、无子模块、版本锁定。
# ---------------------------------------------------------------------------
[workspace.dependencies]
ngx = { path = "vendor/ngx-rust" }
nginx-sys = { path = "vendor/ngx-rust/nginx-sys" }
ipass-core = { path = "crates/ipass-core" }
plugin-sso = { path = "crates/plugin-sso" }
plugin-domain = { path = "crates/plugin-domain" }
# 业务层依赖:全部是纯 Rust 实现,不引入任何系统库或常驻依赖
serde = { version = "1", features = ["derive"] }
serde_json = "1" # 空 Vec / Vec<Map> 天然序列化为 [] / {},前后端契约简单
sha2 = "0.10" # 口令哈希 + JWT 的 HMAC-SHA256 + PKCE S256
getrandom = "0.2" # 会话 token / 授权码 / 客户端密钥;不可退化成可预测伪随机
libc = "0.2" # 仅用于 localtime_r / time / strftime
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
# 模块被加载进 nginx 这个 C 进程,panic 绝不能跨 FFI 边界展开
panic = "abort"
strip = true