Split src/webserver/oidc.rs (1556 lines) into a directory module
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 重构
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- rust
调研方向
Start by reading src/webserver/oidc.rs and its five external call sites listed in the issue, then review the proposed module boundaries. Move the concerns into the listed files while preserving the public re-exports and the lock-free OidcState::snapshot() behavior. Run the integration suite in tests/oidc/mod.rs; done means it passes and the external call sites remain unchanged.
由索引模型根据 Issue 内容生成。
描述
Split-out of the "split oidc.rs" item from #1249.
src/webserver/oidc.rs is the largest file in the codebase at 1556 lines (wc -l src/webserver/oidc.rs). Anyone touching cookie flags has to scroll past JWT verifier generics, HMAC logout signing, the awc transport adapter, and ~12 large openidconnect type aliases. These concerns are independent of each other, and the file's coupling to the rest of the codebase is tiny, so the split is low-risk and high-payoff.
External surface is only 5 symbols
$ grep -rn "oidc::" src | grep -v "src/webserver/oidc.rs"
src/lib.rs:89:use crate::webserver::oidc::OidcState;
src/lib.rs:138: let oidc_state = crate::webserver::oidc::initialize_oidc_state(config).await?;
src/webserver/http.rs:27:use super::oidc::OidcMiddleware;
src/webserver/http_request_info.rs:28:use super::oidc::OidcClaims;
src/webserver/database/sqlpage_functions/functions.rs:1058: if !crate::webserver::oidc::is_safe_relative_redirect(redirect_uri) {
So the entire 1556-line file is reached from outside through just OidcState, initialize_oidc_state, OidcMiddleware, OidcClaims, and is_safe_relative_redirect. A split is almost entirely internal and mechanical.
The concerns are physically interleaved
(line ranges at HEAD 162f996)
- Config / path matching (
OidcConfig,is_public_path,get_app_host) talks only toAppConfig. - Provider discovery + client build (
OidcSnapshot,OidcState,maybe_refresh,build_oidc_client,make_oidc_client) plus the ~12 largeopenidconnecttype aliases (OidcToken,OidcClaims,OidcTokenResponse,OidcClient) that visually dominate the file. - Actix middleware / request routing (
OidcMiddleware,OidcService,handle_requestand thehandle_*family). - Token exchange + claim/nonce verification (
process_oidc_callback,exchange_code_for_token,check_nonce,AudienceVerifier). - Cookie/session + redirect plumbing (the
*_cookiebuilders such asset_auth_cookieandcreate_tmp_login_flow_state_cookie, HMAC logout signingcompute_logout_signature/verify_logout_params,is_safe_relative_redirect,build_redirect_response). - A generic
awctransport adapter (AwcHttpClient, ~110 lines throughAwcWrapperError) implementingopenidconnect::AsyncHttpClientoverawc. This is not OIDC-specific. It ispubbut used only within this file, so it should move to its own module where it becomes independently unit-testable.
Proposed change
Convert to a directory module:
oidc/
mod.rs // re-exports the ~5 public symbols
config.rs // OidcConfig, is_public_path, get_app_host
discovery.rs // OidcState/OidcSnapshot, maybe_refresh, client build, type aliases
middleware.rs // OidcMiddleware/OidcService, handle_request + handle_*
flow.rs // callback / token exchange / claim + nonce verification
session.rs // cookie builders, logout signing, redirect safety
http_client.rs // the AwcHttpClient adapter (now independently testable)
Do not regress the good existing state
Two things must be preserved by the move:
- The real integration suite at
tests/oidc/mod.rs(882 lines) spins up an embedded mock IdP (discovery/jwks/token endpoints) and covers the happy path, CSRF/nonce/signature/audience/issuer/expiry rejection, site-prefix, session-bound logout, and slow-discovery non-blocking behavior. - The lock-free read discipline:
OidcState::snapshot()returns anArc<OidcSnapshot>so request handling never holds theRwLockacross.await. The split must keep this intact.
Risks and mitigations
Purely mechanical move, no behavior change. Mitigations:
- Keep the public re-exports in
mod.rsso no external code changes (the 5 call sites above stay byte-for-byte identical). - Rely on the existing OIDC integration tests above to catch any wiring mistake.
Expected win
Navigable auth code; the transport adapter becomes unit-testable in isolation; and it is a prerequisite for any future second-IdP or server-side-session work.
- 主要语言
- Rust
- 星标
- 2.6k
- 派生
- 175
- 平均合并
- 14 小时 16 分钟
- 30 天内合并 PR
- 43
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sqlpage/SQLPage 的其他 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
sqlpage/SQLPage#1218 · 3 条评论 ·
维护者通常 1 天内回复
-
There is no convenient way to reproduce issues可能已有人在做 @81reap 于 26 天前认领。 未关闭enhancement
sqlpage/SQLPage#1566 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Confusing sort interface可能已有人在做 @lovasoa 于 73 天前认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 20/100
sqlpage/SQLPage#1442 · 3 条评论 ·
维护者通常 1 天内回复
-
Mutation Testing Results :: Dead Code + Missing Tests可能重新可做 @81reap 于 61 天前认领,目前没有进行中的 PR。 未关闭
sqlpage/SQLPage#1396 · 5 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
symposium-dev/symposium#530 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
topgrade-rs/topgrade#2540 ·
维护者通常 1 天内回复
-
Invalid JSON options for ngram and edge_ngram silently use defaults可能已有人在做 @Tilendlesa 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
noemaforge/vimanam#153 ·
维护者通常 1 天内回复