Repository navigation
feat: decision items #88-3 / #105 / #110 — client_id logout, coverage ratchet, key rotation - #176
Conversation
…ation, coverage ratchet gate, signing-key rotation keystore All three ratified by an adversarial re-review on current master (post #156/#157); recommendations A/B/B confirmed unchanged, with #110-C noted as degenerate (key rotation is the last remaining IAM-M1 item, and the repo ships no helm/compose signing-key carrier, so the multi-secret concern was moot). #88-3 (decision A): end_session accepts client_id as the RP identification when id_token_hint is absent (RP-Initiated Logout 1.0 §2.1); the post_logout_redirect_uri must still be registered for that client (same validateRedirectUri gate the aud candidates use — no open redirect; session termination semantics unchanged, and a parameterless end_session already logged out with no proof). With neither hint nor client_id the 400 envelope stands. 3 new integration cases + 2 regressions. #105 (decision B): local coverage ratchet. measure_coverage.py gains --json and --ratchet BASELINE (fail when a non-exempt library drops >0.5pp below baseline; <200-instrumented-line libs exempt; baseline lib missing from the run fails = lost instrumentation; new libs pass until next re-baseline; absent baseline = seed mode printing the JSON). coverage.yml gates the existing job (seconds of added compute). Baseline JSON is committed in a follow-up commit seeded from the first CI run. #110 (decision B): signing-key rotation keystore. JwkManager loads a multi-key store (signing_keystore_dir: <kid>.pem files + active_kid marker), signs with the active kid, verifies by routing on the JWT header kid across all loaded keys (absent kid tries all — RFC 7515 §4.1.4), and publishes EVERY key in JWKS. A configured-but-broken keystore is a hard startup failure (no silent fallback to another key source); the keystore takes precedence over the single-key env/path sources. Rotation is a documented 3-restart procedure (publish → switch → retire; see configuration-guide §9, rewritten from the F-029 to-do). GET /api/admin/oidc/keys now reports the live keystore (keys[] with active/published status) instead of the hardcoded stub; ConfigManager's production key check accepts signing_keystore_dir; endpoint scripts assert the new shape. 7 new keystore unit tests (44/44 in JwkManagerTest). Sync: openapi (end_session client_id param + description, jwks multi-key note, admin keys response) + regenerated openapi.json/Python/Go SDKs; api-diff baseline ratified --force (private-member/static-signature changes with no released consumer); all 8 static gates green; full_test 8/8. Fixes #88 Fixes #105 Fixes #110
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…ion-proof script assertions, JWKS cache note, workflow paths Adversarial review verdict FIX-FIRST with one required fix (commit the ratchet baseline before merge -- landing next, seeded from this PR's CI) and four recommended minors, all applied: - MINOR-1: loadPemInto rejects non-RSA keys (an EC/Ed25519 pem would silently vanish from the JWKS and, as active, sign ECDSA under an alg=RS256 header no RP can verify). - MINOR-2: an unopenable keystore <kid>.pem is a hard init failure -- silently skipping it would no-op rotation step 1 (Publish). - MINOR-4: test-admin-endpoints.sh asserts exactly-one-active keyed by active_kid instead of keys[0].status (keys[0] is filename-sorted and may be a retiring 'published' key under real rotation). - NOTE: configuration-guide §9 step 1 now says to wait out the JWKS Cache-Control max-age (1h) before flipping active_kid. - MINOR-3: coverage.yml paths include tools/coverage/** so baseline-only PRs still run the gate they edit. JwkManagerTest 44/44 after the hardening.
… loud and locatable Two CI failures surfaced by this PR's runs: 1. JwkManagerTest.VerifyJwt_Expired_IsExpired_IncludingExactBoundary is a 1-second wall-clock race (PRE-EXISTING): validClaims(0) took a FRESH std::time, so a tick between the test's captured now and token minting flipped the boundary assertion from Expired to Ok. The new explicit-base validClaims(offset, base) overload pins exp and the verification instant to the same now (25x repeat green; the added keystore tests had merely shifted scheduling enough to trip it). 2. The coverage pipeline has produced ZERO gcov JSON reports since its first run (pre-existing, masked by '|| true' + '>/dev/null'): gcov -j -p writes <mangled-path>.gcov.json.gz into the CURRENT directory, not next to the .gcda, so 'find libs' never saw them and every summarize/ratchet output -- including the ratchet's first seed -- was empty. The step now reports repo-wide vs libs/ counts, relocates cwd-left reports into libs/, and HARD-FAILS on zero instead of masking (a permanently-empty gate is worse than no gate).
…I run The gcov relocation fix produced 166/166 reports; this baseline is the verbatim seed JSON from that run (7 libs: common 74.3, drogon 57.8, identity 87.1, oauth2 88.8, storage-memory 97.0, storage-postgres 54.1, storage-redis 62.2). Review MAJOR-1 resolved: the gate is armed as of this commit -- any library dropping >0.5pp below these numbers fails CI.
|
对抗评审处置完毕(FIX-FIRST 必修项 + 全部 4 个推荐 minor + 两个 CI 意外发现),HEAD ff53b15: MAJOR-1(必修):基线已随本 PR 落地,且带出并修复了一个预先存在的管道缺陷按计划从本 PR 自己的 CI seed——第一次 seed 输出是空基线,深挖发现这不是 ratchet 的问题:覆盖率管道自首次运行(08-28)就产出 0 份 gcov JSON 报告, MINOR(4/4 已修,c913383a)
评审之外的 CI 发现(均已修,90a19cd6)
未处理(按评审 NOTE 级放行)active_kid 前导空白不对称(fail-closed 方向,信息里有 marker 值)、 验证full_test 8/8;JwkManagerTest 44/44;8 项静态门全绿;oasdiff 干净;CI 13 pass + SDK smoke 收尾中;ratchet 门控模式首跑 OK。 |
voidvec
left a comment
There was a problem hiding this comment.
Code review — #88-3 / #105 / #110-B
Reviewed ff53b15a against master (merge-base 6435f781; the checked-out tree matches the remote head commit exactly). Overall: architecture is sound, fail-closed behavior is consistent, test coverage is strong — no [CRITICAL]/[MAJOR] blockers. Four inline comments below; everything else:
[NIT] keystore unit tests leave $TEMP/jwkstore_* dirs behind across runs (writeKeystoreDir/makeKeystoreDir use a counter prefix and the leading remove_all prevents contamination, so correctness is unaffected) — optional teardown cleanup.
[INFO] admin GET /api/admin/oidc/keys response is a breaking schema change (flat kid/kty/alg/key_status → keys[] with per-key status: active|published + active_kid + key_count). Scripts/SDK/docs are in sync, so it is a controlled break — worth one line in the CHANGELOG for external admin integrators.
[INFO] the ratchet baseline is seeded from this PR's own CI run, so the gate only binds from the next PR onward (documented decision). Before merge, a quick sanity check that no lib (esp. oauth2, +334 lines) regressed vs master would be nice since there is no master baseline to diff against — oauth2 88.8% includes all new code plus the 7 keystore tests, so it looks healthy.
[INFO] no-session end_session with a verified hint fans out backchannel logout from hintSub (SessionController.cc 2023-2027). Post-#78 this requires a valid, unexpired id_token, so it is not a new surface — flagging the tradeoff (id_token secrecy matters here) for the record; consider a decision note.
I also compared the push vs pull_request path filters in coverage.yml: the asymmetry (push lacks the script/workflow/CMake entries) is pre-existing on master, not introduced by this PR — this PR adds tools/coverage/** symmetrically to both triggers. No action needed here.
Conclusion: no blockers; the two [MINOR]s are cheap consistency fixes worth doing before merge, #3 could be a follow-up.
| (RP-Initiated Logout 1.0 §2.1). The post_logout_redirect_uri must be | ||
| registered for this client (#88-3).' | ||
| in: query | ||
| name: client_id |
There was a problem hiding this comment.
[MINOR] client_id is documented here for the GET variant (#88-3), but the POST /oauth2/end_session variant in this same file was not updated: it still only declares id_token_hint/post_logout_redirect_uri/state, and its 400 description still reads "missing hint for a supplied post_logout_redirect_uri". Since GET and POST are registered to the same endSession handler (SessionController.cc 1876-1888) reading req->getParameters(), POST + client_id actually works in the implementation — the gap is spec/SDK-side (generated Python/Go POST clients won't expose the parameter). Suggest declaring client_id on the POST variant too and unifying the 400 text, then re-running the SDK regen.
| const bool hasEnvKey = keyEnv && std::strlen(keyEnv) > 0; | ||
| const bool hasEnvPath = keyPathEnv && std::strlen(keyPathEnv) > 0; | ||
| if (!hasEnvKey && !hasEnvPath && configKeyPath.empty()) | ||
| if (!hasEnvKey && !hasEnvPath && configKeyPath.empty() && configKeystoreDir.empty()) |
There was a problem hiding this comment.
[MINOR] configKeystoreDir now counts as a valid production signing-key source (#110-B), but the production-gate tests in tests/unit/config/ConfigManagerTest.cc only cover env and signing_key_path. This branch is the gate for keystore deployments — a misconfiguration slips past validate() and only hard-fails later when OAuth2Plugin exits. Suggest one test: plugins → OAuth2Plugin → config.oidc.signing_keystore_dir non-empty ⇒ validate() == true.
| ) | ||
| continue | ||
| base_pct = float(entry["pct"]) | ||
| if tot[lib] < MIN_LINES: |
There was a problem hiding this comment.
[MINOR] The exemption is keyed on the current run's instrumented-line count. If a library that has thousands of lines in the baseline loses most of its data in a run (test crash / partial instrumentation) and lands below MIN_LINES, it gets exempted instead of failing; only a library that vanishes entirely from tot fails today. Suggest basing the exemption on the baseline total: if base_total >= MIN_LINES but the current total collapses below MIN_LINES, that should FAIL — exempt only when the baseline total itself is < MIN_LINES.
| if (!item.is_regular_file()) | ||
| continue; | ||
| const std::string filename = item.path().filename().string(); | ||
| if (filename.size() <= 4 || filename.substr(filename.size() - 4) != ".pem") |
There was a problem hiding this comment.
[NIT] Suffix check is case-sensitive — an operator naming a key <kid>.PEM (Windows) silently gets it skipped, and the active_kid marker trimming only strips trailing whitespace (291-297), so a leading space would mismatch too. Both end in a hard fail (safe direction), just potentially confusing log output. Optional: case-insensitive suffix match, trim both ends of the marker line, and state the conventions (lowercase .pem, no leading whitespace) in the hard-fail messages.
…ir gate test, baseline-keyed ratchet exemption, keystore filename hardening, changelog Review round 2 (no blockers; 3 MINOR + 1 NIT + INFOs, all addressed): - MINOR-1: openapi declares client_id on the POST /oauth2/end_session variant too (the handler reads it already) and the 400 text is unified across GET/POST; SDKs regenerated. - MINOR-2: ConfigManager production-gate test for oidc.signing_keystore_dir as a standalone key source (misconfiguration now fails validate() with the signing-key message instead of only at plugin exit). - MINOR-3: the ratchet exemption is keyed on the BASELINE total, not the current run's -- a library whose instrumented lines collapse below MIN_LINES while its baseline was above now FAILS with an explicit 'partial instrumentation' message (synthetic scenarios verified: healthy=OK, collapse=FAIL, baseline-tiny=exempt). - NIT: keystore .pem suffix match is case-insensitive AND opens the ACTUAL filename (opening kid+'.pem' on a case-sensitive FS would have turned a detected .PEM into a hard fail); active_kid marker trims both ends. - INFO: CHANGELOG [Unreleased] records the admin /api/admin/oidc/keys response-shape change for external integrators plus the two features. Verified: build green, JwkManagerTest 44/44, new config gate test + hint end_session regression green, all static gates + governance + oasdiff clean.
|
评审第二轮处置完毕(3 MINOR + 1 NIT 全修,INFO 逐条回应),HEAD 7463a9a: MINOR(3/3 已修)M1 POST 变体缺 client_id 声明 — openapi 的 POST /oauth2/end_session 现在声明 client_id(实现侧本就经 M2 keystore 目录缺 validate() 门测试 — 新增 M3 豁免键在当前运行总行数上 — 已改为键在基线总行数:基线 ≥ MIN_LINES 而当前塌缩到 < MIN_LINES 直接 FAIL(消息明说 "partial instrumentation or a crashed test run");只有基线本身 < MIN_LINES 的库才豁免。三个合成场景实证:healthy=OK / collapse=FAIL / baseline-tiny=exempt。 NIT(已修,含一处自查加固)
INFO 逐条
验证构建绿;JwkManagerTest 44/44;新增 config 门测试 + hint 端到端回归绿;api-diff/naming/migration/governance/oasdiff 全绿;CI 重跑中。 |
…ion-proof script assertions, JWKS cache note, workflow paths Adversarial review verdict FIX-FIRST with one required fix (commit the ratchet baseline before merge -- landing next, seeded from this PR's CI) and four recommended minors, all applied: - MINOR-1: loadPemInto rejects non-RSA keys (an EC/Ed25519 pem would silently vanish from the JWKS and, as active, sign ECDSA under an alg=RS256 header no RP can verify). - MINOR-2: an unopenable keystore <kid>.pem is a hard init failure -- silently skipping it would no-op rotation step 1 (Publish). - MINOR-4: test-admin-endpoints.sh asserts exactly-one-active keyed by active_kid instead of keys[0].status (keys[0] is filename-sorted and may be a retiring 'published' key under real rotation). - NOTE: configuration-guide §9 step 1 now says to wait out the JWKS Cache-Control max-age (1h) before flipping active_kid. - MINOR-3: coverage.yml paths include tools/coverage/** so baseline-only PRs still run the gate they edit. JwkManagerTest 44/44 after the hardening.
…I run The gcov relocation fix produced 166/166 reports; this baseline is the verbatim seed JSON from that run (7 libs: common 74.3, drogon 57.8, identity 87.1, oauth2 88.8, storage-memory 97.0, storage-postgres 54.1, storage-redis 62.2). Review MAJOR-1 resolved: the gate is armed as of this commit -- any library dropping >0.5pp below these numbers fails CI.
Implements the three user-ratified decision items (A/B/B). Recommendations were re-verified by an adversarial review on current master before implementation — all three confirmed; #110-C (defer) noted as degenerate since key rotation is the last remaining IAM-M1 item.
#88-3 — end_session client_id identification (decision A)
RP-Initiated Logout 1.0 §2.1 allows the RP to identify itself via
client_idwhenid_token_hintis absent. The aud-candidate chain now seeds fromclient_id, so the post_logout_redirect_uri must still be registered for that client (samevalidateRedirectUrigate — no open redirect; the forced-logout surface is unchanged since a parameterless end_session already terminated sessions). Neither hint nor client_id → the existing 400 envelope.#105 — local coverage ratchet gate (decision B)
measure_coverage.pygains--jsonand--ratchet BASELINE;coverage.ymlgates the existing gcov job:The committed baseline lands in a follow-up commit seeded from this PR's own CI run.
#110 — signing-key rotation keystore (decision B)
JwkManagerbecomes a multi-key store:oidc.signing_keystore_dir:<kid>.pemfiles +active_kidmarker file; filename = kidGET /api/admin/oidc/keysreports the live keystore (keys[] + active/published status + active_kid) instead of the hardcoded stub; endpoint scripts (sh/ps1) assert the new shape; ConfigManager's production key check accepts the keystoreVerification
Fixes #88
Fixes #105
Fixes #110