Skip to content

test: use valid token format in OAuth2InvalidClientHeaderTest - #5

Merged
voidvec merged 2 commits into
masterfrom
fix/deploy-docs-and-gitignore
Jun 24, 2026
Merged

voidvec merged 2 commits into
masterfrom
fix/deploy-docs-and-gitignore

Conversation

@voidvec

@voidvec voidvec commented Jun 24, 2026

Copy link
Copy Markdown
Owner

变更内容

修复测试用例中使用的 token 格式,使其符合验证要求:

  • TOKEN_MIN_LEN = 32 characters
  • TOKEN_PATTERN = ^[a-zA-Z0-9._-]+$

主要修改

测试修复

  • OAuth2InvalidClientHeaderTest.cc: 更新 token 参数格式
    • 将 some_token (10 chars) 替换为 some_valid_token_with_32_characters_min (42 chars)
    • 修复集成测试中的 token 格式验证问题

单元测试

  • SqlSplitterTest.cc: 相关单元测试更新

文档更新

  • 新增部署和测试相关文档:
    • docs/backend/endpoint-test-coverage-analysis.md
    • docs/backend/endpoint-test-implementation-plan.md
    • docs/frontend/test-coverage-gap-analysis.md
    • docs/frontend/test-execution-plan.md
    • docs/ops/deployment-windows-docker-desktop.md
    • docs/ops/verification-checklist.md

配置更新

  • .codegraph/.gitignore: 更新 gitignore 规则

测试结果

✅ 所有测试通过 (55,914 断言,212 测试用例)
✅ 修复的集成测试:

  • Integration_OAuth2InvalidClient_IntrospectReturnsWWWAuthenticateHeader
  • Integration_OAuth2InvalidClient_RevokeReturnsWWWAuthenticateHeader

相关问题

修复了 token 格式验证导致的测试失败问题,确保测试使用符合 OAuth2 规范的 token 格式。

修复测试用例中使用的 token 格式,使其符合验证要求:
- TOKEN_MIN_LEN = 32 characters
- TOKEN_PATTERN = ^[a-zA-Z0-9._-]+$

将 'some_token' (10 chars) 替换为符合格式要求的
'some_valid_token_with_32_characters_min' (42 chars)。

修复后集成测试通过:
- Integration_OAuth2InvalidClient_IntrospectReturnsWWWAuthenticateHeader
- Integration_OAuth2InvalidClient_RevokeReturnsWWWAuthenticateHeader

相关修改:
- OAuth2Server/test/integration/error/OAuth2InvalidClientHeaderTest.cc: 更新 token 参数
- OAuth2Server/test/unit/schema/SqlSplitterTest.cc: 相关单元测试更新
- docs/ops/: 更新部署文档和验证清单

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e52aca4b0a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


```powershell
# 直接使用 docker-compose.yml(已配置好本地端口)
docker compose -f deploy/docker/docker-compose.yml --env-file .env.docker up -d --build

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not document an env file that compose ignores

For the documented Option A, deploy/docker/docker-compose.yml hard-codes POSTGRES_PASSWORD=123456, OAUTH2_DB_PASSWORD=123456, and redis_secret_pass instead of interpolating ${...} values, so the --env-file .env.docker passed here does not apply the passwords the guide just told users to set. Users following this path get containers with the hard-coded credentials while later verification steps use WinDockerTest2024!, which makes Redis authentication and any password-dependent checks fail unless they manually edit the compose file or use the prod compose file.

Useful? React with 👍 / 👎.

CLAUDE.md requires ASCII markers ([+] allowed, [-] forbidden, [!]
warning) instead of emoji in code or output. The two new ops docs
added in this branch used pictographic emoji as status markers
(check/cross/warning/test-tube).

Replace across docs/ops/deployment-windows-docker-desktop.md and
docs/ops/verification-checklist.md (68 lines, no net line change):
- success/check/test markers -> [+]
- cross/failure markers      -> [-]
- warning markers            -> [!]
- drop stray U+FE0F variation selectors

Embedded PowerShell Write-Host markers now read "[+] ..." (Green) and
"[-] ..." (Red), matching the existing color semantics. ASCII flow
diagram borders and arrows were left unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@voidvec
voidvec merged commit 46c80d4 into master Jun 24, 2026
3 checks passed
@voidvec
voidvec deleted the fix/deploy-docs-and-gitignore branch July 1, 2026 10:06
voidvec added a commit that referenced this pull request Jul 29, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
voidvec added a commit that referenced this pull request Jul 29, 2026
…) + comment #4/#8/#9

P1 #6 (RFC 6749 §5.1): expires_in / id_token exp / device refresh TTL were
hardcoded 3600/2592000; now use configured access_token_ttl/refresh_token_ttl
(OAuth2Plugin getAccessTokenTtl()/getRefreshTokenTtl() accessors). 6 sites:
TokenService auth_code expires_in + id_token exp + refresh expires_in;
client_credentials + device_code issuance in TokenEndpointController.

P1 #5 (RFC 8628 §3.4): device_code redemption now authenticates by client_type
-- CONFIDENTIAL clients require a valid client_secret (validateClient); PUBLIC
clients keep the client_id-vs-device-row binding. Lookup wrapped in a local
lambda captured BY VALUE (not [&]) because it runs from getClient's async
callback after token() has returned -- [&] would dangle deviceCodeHash/dbClient.

P1 #3 (RFC 6749 §4.1.2 single-use): device-code redemption check-then-delete
was non-atomic (two concurrent redemptions both issued). Replaced with a
pre-issue atomic UPDATE...WHERE status='approved' RETURNING; affected-row gate
makes exactly one concurrent winner issue, loser gets invalid_grant (fail-
closed). UPDATE...RETURNING is a db-operations.md raw-SQL exemption.

Comment-only (#4 [this] capture, #8 validateAccessToken no-self, #9 JWKS empty
response): document existing-correct behavior, deter repeat review reports.

Tests (live-server integration, PG+Redis): TokenExpiryTtlConfigTest,
DeviceCodeClientAuthTest (conf no-secret rejects / conf secret ok / pub ok),
DeviceCodeRaceConditionTest (concurrent redemption -> exactly one wins).
All pass + no regressions (RFC6749 compliance 4504 assertions, auth_code E2E,
refresh rotation, authorize PKCE passthrough).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
voidvec added a commit that referenced this pull request Aug 9, 2026
Addresses the actionable items from the PR #44 code review (benchmark
review intentionally excluded).

MINOR #1 (RateLimiter unbounded memory growth): RateLimiter.purgeOldLocked
only ran for the accessed key, so attacker keys recording one failure and
never touched again lingered indefinitely -> unbounded map growth under a
distributed attack. Added RateLimiterConfig.maxBuckets (default 10000) and a
sweepLocked() full purge triggered in recordFailure when the bucket count
exceeds the cap (drops every bucket with no in-window failures). Triggered
on the growth path, not the hot checkThrottled path.

MINOR #2 (scope.find("openid") substring vs token match): userInfo + the
device id_token path used scope.find("openid") (substring), inconsistent
with the new hasScope() token match and susceptible to a `myopenid`-style
false positive. Converted the two libs/drogon sites to hasScope(); for
TokenService (libs/oauth2, cannot depend on libs/drogon) added a
framework-free scopeContains() in the anonymous namespace and converted the
auth-code + refresh id_token-issuance sites.

MINOR #3 (Postgres LOG_DEBUG match result): removed the
"Secret validation PASSED/FAILED" LOG_DEBUG to match the Redis path's F-004
removal (the match result is already observable via the HTTP status, so this
is a uniformity fix, not a timing-side-channel fix).

NIT #5 (error param urlEncode): buildAuthorizeErrorRedirect now urlEncodes
the `error` param for defensive consistency with error_description/state.

MINOR #4 (refresh_token double getClient): intentionally NOT fixed in this
PR -- the reviewer flagged it as a non-blocking perf opportunity
(redundant DB round-trip). Threading the client optional through
dispatchGrant is invasive; deferred.

Verified: build GREEN with AUTHFORGE_WERROR=ON (CI parity);
manage.ps1 test-backend = 456/456; api-diff OK (additive RateLimiter
declarations ratified at v1.0.0).
voidvec added a commit that referenced this pull request Aug 9, 2026
Addresses the actionable items from the PR #44 code review (benchmark
review intentionally excluded).

MINOR #1 (RateLimiter unbounded memory growth): RateLimiter.purgeOldLocked
only ran for the accessed key, so attacker keys recording one failure and
never touched again lingered indefinitely -> unbounded map growth under a
distributed attack. Added RateLimiterConfig.maxBuckets (default 10000) and a
sweepLocked() full purge triggered in recordFailure when the bucket count
exceeds the cap (drops every bucket with no in-window failures). Triggered
on the growth path, not the hot checkThrottled path.

MINOR #2 (scope.find("openid") substring vs token match): userInfo + the
device id_token path used scope.find("openid") (substring), inconsistent
with the new hasScope() token match and susceptible to a `myopenid`-style
false positive. Converted the two libs/drogon sites to hasScope(); for
TokenService (libs/oauth2, cannot depend on libs/drogon) added a
framework-free scopeContains() in the anonymous namespace and converted the
auth-code + refresh id_token-issuance sites.

MINOR #3 (Postgres LOG_DEBUG match result): removed the
"Secret validation PASSED/FAILED" LOG_DEBUG to match the Redis path's F-004
removal (the match result is already observable via the HTTP status, so this
is a uniformity fix, not a timing-side-channel fix).

NIT #5 (error param urlEncode): buildAuthorizeErrorRedirect now urlEncodes
the `error` param for defensive consistency with error_description/state.

MINOR #4 (refresh_token double getClient): intentionally NOT fixed in this
PR -- the reviewer flagged it as a non-blocking perf opportunity
(redundant DB round-trip). Threading the client optional through
dispatchGrant is invasive; deferred.

Verified: build GREEN with AUTHFORGE_WERROR=ON (CI parity);
manage.ps1 test-backend = 456/456; api-diff OK (additive RateLimiter
declarations ratified at v1.0.0).
voidvec added a commit that referenced this pull request Aug 14, 2026
… fixes

Critical #1: soft-deleted users can no longer log in
- PostgresIdentityRepository: add deleted_at IS NULL filter to
  findByEmail, findByUsername, findById, findByPublicSub, getUserInfoWithRoles,
  getRoles(subject) — blocks login, userinfo, and token-issuance role resolution
- deleteUser: revoke all access + refresh tokens for the deleted user
  (introspection/refresh copy subject from token rows, never query users)

High #2: getUser now returns org_id in the response JSON

Medium #3: listUsers search escapes LIKE wildcards (%/_) in query param q

Medium #5: createUser/updateUser guard org_id/locked type coercion
  with isInt()/isBool() to prevent uncaught Json::LogicError in async callbacks

Medium #6: deleteUser rejects self-deletion (admin cannot delete own account)
voidvec added a commit that referenced this pull request Aug 14, 2026
… fixes

Critical #1: soft-deleted users can no longer log in
- PostgresIdentityRepository: add deleted_at IS NULL filter to
  findByEmail, findByUsername, findById, findByPublicSub, getUserInfoWithRoles,
  getRoles(subject) — blocks login, userinfo, and token-issuance role resolution
- deleteUser: revoke all access + refresh tokens for the deleted user
  (introspection/refresh copy subject from token rows, never query users)

High #2: getUser now returns org_id in the response JSON

Medium #3: listUsers search escapes LIKE wildcards (%/_) in query param q

Medium #5: createUser/updateUser guard org_id/locked type coercion
  with isInt()/isBool() to prevent uncaught Json::LogicError in async callbacks

Medium #6: deleteUser rejects self-deletion (admin cannot delete own account)
voidvec added a commit that referenced this pull request Aug 30, 2026
…loor, bootstrap self-heal, review cleanups

Address PR #141 review (1 must-fix, 8 should-fix, quick considers):

- #1 consent_csrf declared as a required query parameter in openapi.yaml
  and the C++ endpoint doc registration; apps/server/docs/api/openapi.json
  regenerated from a live server run; Python/Go clients regenerated.
- #2 nonce one-shot is now atomic: the find/verify/erase sequence is
  serialized by a process-wide mutex (consent traffic is tiny; in-process
  session storage).
- #3 identity AuthService no longer captures this in the async validateUser
  callback — the legacy-hash policy flag is value-captured
  (db-operations rule 4).
- #4/#12 AdminBootstrapper reworked as ensure-* steps: an existing admin
  user row is reused and role/mapping completed (partial failures self-heal
  on restart); the random password is printed only after the insert
  succeeded; a mapping failure no longer reports created=true.
- #5 POST /api/admin/users enforces auth.min_password_length
  (VALIDATION_PASSWORD_TOO_SHORT) — closing the admin bypass.
- #6 consent integration tests reworked: missing-nonce now drives the real
  authorize-minted slot (400), deny-to-unregistered-uri (400, no Location)
  and deny-to-registered-uri (302 access_denied) branches are covered.
- #7/#8 deployment.md: auto-bootstrap wording fixed, bogus ADMIN_SALT
  removed (PBKDF2 keeps salt empty); website i18n error table mirrored
  (3014/4007).
- #9 main.cc bootstrap probes with backoff (5 attempts) and LOG_WARN on
  failure instead of a single silent 2s probe.
- #13 unique-violation detection layered (SqlError 23505 -> constraint
  name -> english/zh localized text), mirroring the
  PostgresSocialAccountRepository pattern.
- #11 gate-4 comment corrected; #15 CHANGELOG duplicate Unreleased merged;
  #17 AGENTS.md consent.csp entry removed.

Considered-but-not-taken: #10 multi-slot nonces (tracked follow-up), #14
admin UI hardcode (server now enforces; hint stays), #18 MFA-pending
session through consent (pre-existing authorize behavior, tracked).
voidvec added a commit that referenced this pull request Aug 30, 2026
…loor, bootstrap self-heal, review cleanups

Address PR #141 review (1 must-fix, 8 should-fix, quick considers):

- #1 consent_csrf declared as a required query parameter in openapi.yaml
  and the C++ endpoint doc registration; apps/server/docs/api/openapi.json
  regenerated from a live server run; Python/Go clients regenerated.
- #2 nonce one-shot is now atomic: the find/verify/erase sequence is
  serialized by a process-wide mutex (consent traffic is tiny; in-process
  session storage).
- #3 identity AuthService no longer captures this in the async validateUser
  callback — the legacy-hash policy flag is value-captured
  (db-operations rule 4).
- #4/#12 AdminBootstrapper reworked as ensure-* steps: an existing admin
  user row is reused and role/mapping completed (partial failures self-heal
  on restart); the random password is printed only after the insert
  succeeded; a mapping failure no longer reports created=true.
- #5 POST /api/admin/users enforces auth.min_password_length
  (VALIDATION_PASSWORD_TOO_SHORT) — closing the admin bypass.
- #6 consent integration tests reworked: missing-nonce now drives the real
  authorize-minted slot (400), deny-to-unregistered-uri (400, no Location)
  and deny-to-registered-uri (302 access_denied) branches are covered.
- #7/#8 deployment.md: auto-bootstrap wording fixed, bogus ADMIN_SALT
  removed (PBKDF2 keeps salt empty); website i18n error table mirrored
  (3014/4007).
- #9 main.cc bootstrap probes with backoff (5 attempts) and LOG_WARN on
  failure instead of a single silent 2s probe.
- #13 unique-violation detection layered (SqlError 23505 -> constraint
  name -> english/zh localized text), mirroring the
  PostgresSocialAccountRepository pattern.
- #11 gate-4 comment corrected; #15 CHANGELOG duplicate Unreleased merged;
  #17 AGENTS.md consent.csp entry removed.

Considered-but-not-taken: #10 multi-slot nonces (tracked follow-up), #14
admin UI hardcode (server now enforces; hint stays), #18 MFA-pending
session through consent (pre-existing authorize behavior, tracked).
voidvec added a commit that referenced this pull request Nov 12, 2026
…release three-part gate docs

Closes the two v1.6.0 frontend-leg gaps from the 2026-11 P0/P1 retro
audit (#4: logs/export had no consumer; claim-mappings had no UI — the
follow-up declared in #293) and processizes the pre-release three-part
gate that v1.5.0 silently skipped (#5).

- Audit Logs page: time-windowed Export CSV action (datetime-local
  inputs; empty from/to defaults to the last 24h so the mandatory-window
  contract is never tripped by accident), blob download, and a
  blob-decoding error path so AUDIT_EXPORT_WINDOW_REQUIRED /
  AUDIT_EXPORT_TOO_LARGE surface through the normal catalog messages.
- New Claim Mappings page (/admin/claim-mappings, nav under Scopes):
  create/edit modals with the scope-name datalist and the
  custom_attributes.<key> / user.display_name source-whitelist hint,
  row-level enable toggle issuing the documented full-replace PUT,
  confirm-guarded delete — mirrors the P1-3 red lines in the mock and
  specs (reserved-claim 400, openid-scope 400).
- Release process: versioning-and-release.md gains the pre-release
  three-part gate section (five-scenario benchmark >= 90% in-tree,
  curated CHANGELOG, six-point version sync) in EN + zh mirror; the
  release-engineering checklist gains the same blocking gate; the PR
  template gains a release-PR checklist section.
- e2e: logs.spec +2 (window params, catalog error), claim-mappings.spec
  new (5 cases incl. contract-body assertions). Mock-api gains the
  export route (window guard + text/csv) and an in-memory claim-mappings
  CRUD mirroring the server red lines.

Verification: admin tsc+vite build green; vitest 4/4; Playwright
logs(12) + claim-mappings(5) + navigation/i18n regression suites green;
zh-mirror consistency 51/51; doc-links 356 green; llms regen zero drift.
voidvec added a commit that referenced this pull request Nov 12, 2026
…release three-part gate docs

Closes the two v1.6.0 frontend-leg gaps from the 2026-11 P0/P1 retro
audit (#4: logs/export had no consumer; claim-mappings had no UI — the
follow-up declared in #293) and processizes the pre-release three-part
gate that v1.5.0 silently skipped (#5).

- Audit Logs page: time-windowed Export CSV action (datetime-local
  inputs; empty from/to defaults to the last 24h so the mandatory-window
  contract is never tripped by accident), blob download, and a
  blob-decoding error path so AUDIT_EXPORT_WINDOW_REQUIRED /
  AUDIT_EXPORT_TOO_LARGE surface through the normal catalog messages.
- New Claim Mappings page (/admin/claim-mappings, nav under Scopes):
  create/edit modals with the scope-name datalist and the
  custom_attributes.<key> / user.display_name source-whitelist hint,
  row-level enable toggle issuing the documented full-replace PUT,
  confirm-guarded delete — mirrors the P1-3 red lines in the mock and
  specs (reserved-claim 400, openid-scope 400).
- Release process: versioning-and-release.md gains the pre-release
  three-part gate section (five-scenario benchmark >= 90% in-tree,
  curated CHANGELOG, six-point version sync) in EN + zh mirror; the
  release-engineering checklist gains the same blocking gate; the PR
  template gains a release-PR checklist section.
- e2e: logs.spec +2 (window params, catalog error), claim-mappings.spec
  new (5 cases incl. contract-body assertions). Mock-api gains the
  export route (window guard + text/csv) and an in-memory claim-mappings
  CRUD mirroring the server red lines.

Verification: admin tsc+vite build green; vitest 4/4; Playwright
logs(12) + claim-mappings(5) + navigation/i18n regression suites green;
zh-mirror consistency 51/51; doc-links 356 green; llms regen zero drift.
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.

2 participants