Skip to content

fix(storage): preserve access-token timestamps and reject future introspection nbf - #344

Merged
voidvec merged 1 commit into
masterfrom
fix/token-timestamps-342
Nov 19, 2026
Merged

voidvec merged 1 commit into
masterfrom
fix/token-timestamps-342

Conversation

@voidvec

@voidvec voidvec commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fresh access tokens could introspect as inactive because PostgreSQL rounded default not_before to the next second. Explicitly persist issuance/not-before on single-token, pair and rotation writes, preserving nonzero caller values and resolving zero-valued inputs from one captured application second. Read both fields back into the DTO.

Memory, Redis and PostgreSQL access-token introspection also reject intentionally future not_before values. Cache enforcement, existing expiry boundaries, refresh semantics and transaction/callback completion remain unchanged. This does not unify every Bearer-validation path. No schema, migration, generated ORM, public SDK or controller changes.

Fixes #342

Validation

  • Independent plan and implementation review passed.
  • All seven new real-service contract cases failed on the old implementation; three private-helper cases passed. Final ten regression cases passed with real PostgreSQL/Redis, including fractional .25/.75 boundaries, independent/default fields, three write paths, future nbf and real cache/fallback behavior.
  • Standalone fix: complete main binary 756 cases / 62,387 assertions; all five library binaries (529 tests) and out-of-process endpoints passed.
  • Explicitly unmerged composite with fix(observability): export bounded cache counters through PromExporter #345 and perf: add S07 capacity harness with cache and telemetry fixes #343: complete main binary 756 cases / 62,444 assertions, 12 adapter tests and endpoints passed. All 18 default/tuned protocol smoke rows passed, including the real cache hit/miss proof gates. Both profiles used 4 VU, 0.2-second warmup and the existing six-second smoke option to cross the exporter's five-second snapshot cache.
  • All six repository gates and relevant source/doc checks passed. The earlier-head CI, Security, Coverage and Sanitizers succeeded; those results are historical after rebasing.

The combined smoke verifies functional flows and metrics, not capacity or clean shutdown: abnormal server-stop outcomes are retained separately under the #300 exclusion. Full raw runs and credentials remain private. Formal S07 still needs persistent-space provisioning and a successful pilot budget; no matrix/soak/fault acceptance or merge/deployment is claimed.

Checklist

  • Regression tests and complete relevant suites passed
  • CHANGELOG updated
  • Public API/schema/SDK synchronization not required

Bug fix, non-breaking.

Integration with current master (2026-11-19)

Rebased onto f720d5d9 after #339/#343/#354. Current head: 7884511d79a0d9c465967aceaca0b81dde807555.

The only manual conflict was CHANGELOG; both Unreleased entries were retained. All six production/new-test blobs are byte-identical to the previously reviewed head. The CMake net change remains exactly the seven timestamp contract registrations, with upstream feature guards retained. Zero-context stable patch IDs match; the normal patch ID differs because CHANGELOG context changed. Native and published trees match exactly. Spec/API/double-move/migration/naming/macro/architecture/manage-parity checks passed locally.

The final update over #354 changed only the base's seven admin frontend files: all backend/test/CHANGELOG blobs are unchanged, and the full stable patch ID is identical before and after that update. Native/published tree: 5dcba5b8eb34ff33b7ccb23eccf4c9f1648b320e.

The #343 authoritative-cache fallback remains intact. No further repository or timestamp semantics changed during this rebase. Fresh current-head CI and repository review protection are required before the user-authorized rebase merge; previous-head results are not counted as current-head acceptance.

@voidvec

voidvec commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

必须处理项

评审基于 b62762a3bc657de70795084a14444c41d0839628。

本轮未发现需要阻断合并的新增缺陷。

已核对:PostgreSQL 单 token、事务 token pair、refresh rotation 共用时间戳赋值路径;两个零值字段使用同一次捕获的应用时间,显式值分别保留;读取补齐 issued_at/not_before;Memory、Redis、PostgreSQL introspection 均增加未来 nbf 拒绝,原有事务/回调与过期边界未被改动。新增测试已接入源码收集与 Contract 注册。

当前 head 的三平台 CI、ASan+UBSan、SDK smoke 均成功;严格 coverage gate 和 nightly TSan 为跳过,不能算作已验证。本轮为差异及关联代码审查,没有在本机重新执行 C++/数据库全套测试。其他 Bearer 路径的一致性属于 PR 已声明的范围外事项,未据此要求扩大本次修复。

@voidvec

voidvec commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

建议处理项

评审基于 b62762a3bc657de70795084a14444c41d0839628。

1. 补充默认时间戳经过缓存的冷暖一致性用例

位置:TokenTimestampContractTest.cc:264–278、296–303。

现有缓存用例均传入明确的非零 issuedAt/notBefore;零值默认化只在直接 PostgreSQL 写读路径验证。现有 RedisCachedTokenRepository 的写后预热保存的是输入 DTO,而本 PR 的 PostgreSQL 会在内部解析零值,因此值得补测 issuedAt=0/notBefore=0 及单字段为零时,暖缓存、清缓存后回源、introspection 对时间戳的返回口径。

建议使用独立 token,比较实际持久化值与各条读取路径,而不只断言 active。缓存预热逻辑未在本 PR 修改,此项作为覆盖和契约澄清建议,不将其直接认定为本次新增阻断缺陷。

wangrh0909
wangrh0909 previously approved these changes Nov 18, 2026
@wangrh0909
wangrh0909 force-pushed the fix/token-timestamps-342 branch from b62762a to e9b1015 Compare November 18, 2026 04:03
@voidvec
voidvec force-pushed the fix/token-timestamps-342 branch from e9b1015 to edbcfbd Compare November 19, 2026 01:34
@voidvec
voidvec marked this pull request as ready for review November 19, 2026 01:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T01:36:41.482973Z edbcfbd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…ion nbf

Persist explicit iat/nbf and resolve unspecified values from one application second on every PostgreSQL write path; round-trip the fields and reject future access-token nbf during backend introspection. Cover writes, rotation, fractional seconds, and real cache/fallback behavior.

Fixes #342
@voidvec
voidvec force-pushed the fix/token-timestamps-342 branch from edbcfbd to 7884511 Compare November 19, 2026 02:00
@voidvec
voidvec merged commit f5f98be into master Nov 19, 2026
19 checks passed
@voidvec
voidvec deleted the fix/token-timestamps-342 branch December 2, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fresh access tokens can introspect inactive due to rounded PostgreSQL nbf defaults

2 participants