Files
sso/source/rust/Cargo.toml
T
ssw c8a02b8c49 feat: 从网关项目剥离为独立 SSO 统一认证服务
定位:身份层(IdP + IAP),不含动态域名转发 / LLM 上游代理 / 用量计费。

代码(source/rust,nginx 动态模块 + Rust,单进程零外部依赖)
- IdP:authorization_code(含 PKCE)/ refresh_token / client_credentials / password
  四种 grant,含 discovery / introspect / userinfo / jwks 占位
- IAP:access 阶段门禁,注入 X-Auth-* 到后端,客户端伪造同名头被覆盖
- MaxKey 互通:/oauth/v20/* 与 /oauth2.0/* 别名 + context-path 归一化 + 扁平字段
- 管理接口:账号(含角色/部门/用户组)与 OAuth 接入方注册表,热写穿共享内存
- 模块改名 ngx_http_sso_module,指令 sso_state / sso_data_dir / sso_api / sso_iap,
  Cookie sso_sid(终端用户)与 sso_admin_session(管理员)两套身份两套会话

配置(source/conf)
- nginx.conf 生产模板(TLS、IAP 子域、含 auth_sub 的日志格式)
- nginx.test.conf 本机验证配置(明文 18095-18099)
- tls/README.md 证书约定与公钥比对校验

前端(source/www/admin.html)
- 三 tab:账号管理 / 接入方 / 接入指南;去掉审核队列、域名、LLM 上游、用量统计

测试与脚本
- tests/ 三套端到端:协议基线 14 项 · MaxKey 互通与接入 24 项 · 管理接口 31 项,全绿
- tests/demo-system 演示业务系统(Python 标准库),覆盖应用自建客户端与 IAP 零改造两种姿势
- scripts/run-local-e2e.sh 本机一键起停;scripts/seed-data.sh 物化运行时数据目录

文档
- README.md 概览与快速开始;CLAUDE.md 硬约定与排障速查
- docs/design.md 完整设计;docs/roadmap.md 待执行任务(v2 RS256+JWKS、用户管理界面)
2026-09-12 21:42:06 +08:00

53 lines
2.2 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.
# 独立 workspace:vendored 的 ngx-rust 本身是 workspace 根,需显式排除以免歧义
[workspace]
exclude = ["vendor/ngx-rust"]
[package]
name = "sso-gateway"
version = "1.0.0"
edition = "2021"
publish = false
description = "SSO 统一认证网关 —— nginx + Rust 动态模块(自带 OAuth2/OIDC IdP + IAP 身份注入)"
[lib]
# cdylib 给 nginx 加载;rlib 便于单元测试
name = "sso_gateway"
crate-type = ["cdylib", "rlib"]
[features]
default = ["export-modules"]
# 脱离 nginx 构建系统、单独产出动态模块时必须开启(生成 ngx_modules 表)
export-modules = []
[dependencies]
# ⚠️ 依赖必须用 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,调用栈停在
# GitCheckout::update_submodules -> fetch -> wait4)。
#
# 因此 vendor 到 vendor/ngx-rust/,用 path 依赖:离线可编译、无子模块、版本锁定。
ngx = { path = "vendor/ngx-rust" }
nginx-sys = { path = "vendor/ngx-rust/nginx-sys" }
# 业务层依赖:全部是纯 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