Repository navigation
Conversation
voidvec
added a commit
that referenced
this pull request
May 3, 2026
…features Updated README.md: - Added recent security improvements section (RFC 6749 compliance) - Documented new Dashboard page and logout functionality - Added frontend routes documentation - Added interactive API docs link (Swagger UI) - Updated features table with logout endpoint Updated CHANGELOG.md: - Added comprehensive OAuth2 security & compliance changes (2026-05-02) - Documented client authentication (RFC 6749 Section 2.3.1) - Documented redirect URI validation (RFC 6749 Section 4.1.3) - Documented frontend features (Dashboard, Logout, Route Guards) - Documented type system and storage layer changes - Fixed security vulnerabilities section - Updated production status This completes item #1 of the action list: Update project documentation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
voidvec
added a commit
that referenced
this pull request
Jul 29, 2026
…d persist code_challenge (P0 #1) authorize() silently dropped code_challenge/code_challenge_method/nonce on all three branches; now extracted and appended to /login and /consent redirects, passed to generateAuthorizationCode on direct issue, with require_pkce_for_public enforced before direct issue. Companion plumbing: showLoginPage -> login.csp nonce hidden field, ConsentPage.vue reads query params and forwards them. Deeper root cause exposed by the new integration test: PostgresGrantRepository::saveAuthCode never persisted code_challenge/code_challenge_method (getAuthCode read-back missing too), so PKCE was silently bypassed on EVERY path in Postgres mode (TokenService check is conditional on a stored challenge, RFC 7636 4.4). Known residual gap: oauth2_codes has no nonce column; nonce is threaded over HTTP but not persisted (pre-existing schema limitation, recorded in tasks.md L5). Test: tests/integration/auth/AuthorizePkcePassthroughIntegrationTest.cc drives the real direct-issue flow over live HTTP; verifier-less exchange must fail invalid_grant, correct verifier must succeed. ctest 295/295.
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
…og parity Addresses the round-2 review findings (the round-1 MINOR #1 fix had a hole; MINOR #3 parity was incomplete). Round-2 NEW #1 (RateLimiter cap bypassed via checkThrottled): The round-1 fix only ran sweepLocked() in recordFailure, but checkThrottled uses buckets_[key] (operator[] inserts an empty bucket for each new key). An attacker spamming unique (ip, client_id) keys through checkThrottled -- the hot pre-auth path -- WITHOUT ever triggering a failure grew buckets_ without bound; maxBuckets never tripped. Two-part fix: - checkThrottled now detects the new-insert case and runs sweepLocked() when the bucket count exceeds the cap (covers the no-failure growth vector). - sweepLocked now ENFORCES the cap: after purging expired/empty buckets, if the count still exceeds maxBuckets (many keys each holding in-window failures under a distributed attack), it evicts buckets by oldest most-recent failure until under cap. Previously it only dropped empties, so a real attack with non-empty buckets still grew unbounded. Round-2 NEW #2 (Memory log parity incomplete): removed the MemoryClientRepo "Secret validation PASSED/FAILED" LOG_DEBUG to match the Postgres (round-1) and Redis (F-004) removals. Now all three backends are consistent. Added a unit test (Unit_P1_Utils_RateLimiter_CapBoundedOnCheckThrottledInsert) that drives 200 unique keys through checkThrottled with no failures and a maxBuckets=10 cap, then 50 distinct failed keys + an insert, asserting the limiter stays functional and never spuriously throttles a never-failed key. Verified: build GREEN with AUTHFORGE_WERROR=ON (fixed a TimePoint::max() Windows-macro build error with (TimePoint::max)() along the way); manage.ps1 test-backend = 456/456 (incl. the new test's 4 assertions).
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
…og parity Addresses the round-2 review findings (the round-1 MINOR #1 fix had a hole; MINOR #3 parity was incomplete). Round-2 NEW #1 (RateLimiter cap bypassed via checkThrottled): The round-1 fix only ran sweepLocked() in recordFailure, but checkThrottled uses buckets_[key] (operator[] inserts an empty bucket for each new key). An attacker spamming unique (ip, client_id) keys through checkThrottled -- the hot pre-auth path -- WITHOUT ever triggering a failure grew buckets_ without bound; maxBuckets never tripped. Two-part fix: - checkThrottled now detects the new-insert case and runs sweepLocked() when the bucket count exceeds the cap (covers the no-failure growth vector). - sweepLocked now ENFORCES the cap: after purging expired/empty buckets, if the count still exceeds maxBuckets (many keys each holding in-window failures under a distributed attack), it evicts buckets by oldest most-recent failure until under cap. Previously it only dropped empties, so a real attack with non-empty buckets still grew unbounded. Round-2 NEW #2 (Memory log parity incomplete): removed the MemoryClientRepo "Secret validation PASSED/FAILED" LOG_DEBUG to match the Postgres (round-1) and Redis (F-004) removals. Now all three backends are consistent. Added a unit test (Unit_P1_Utils_RateLimiter_CapBoundedOnCheckThrottledInsert) that drives 200 unique keys through checkThrottled with no failures and a maxBuckets=10 cap, then 50 distinct failed keys + an insert, asserting the limiter stays functional and never spuriously throttles a never-failed key. Verified: build GREEN with AUTHFORGE_WERROR=ON (fixed a TimePoint::max() Windows-macro build error with (TimePoint::max)() along the way); manage.ps1 test-backend = 456/456 (incl. the new test's 4 assertions).
voidvec
added a commit
that referenced
this pull request
Aug 11, 2026
… hardening
Codex P1 (REAL, design-doc correctness fix): the design doc §5.4 wrongly
claimed 'no client write path exists today'. Verified ClientManagementService
exposes 4 runtime admin mutation paths (updateClient :280, resetClientSecret
:414, updateClientScopes :517, deleteClient :373) that bypass IClientRepository.
When cache.enabled=true these mutate Oauth2Clients directly without
invalidating authforge:cache:client:{clientId} → stale client served for up
to 300s TTL. Corrected §5.4 + added §8 risk row. Phase-1 mitigation:
cache.enabled defaults false; invalidation hooks are a tracked follow-up.
Owner #2 (REAL): cache.enabled=true + non-postgres storage was a silent no-op.
Added LOG_WARN in both the redis and memory branches so operators see the
cache is ignored.
Owner #1 (partly-fabricated API, but valid kernel): the reviewer's
fromJson()/cached.id API does not exist, but the defense-in-depth idea is
sound — deserializeClient now rejects a structurally-valid-but-empty clientId
as a miss (blank client would mask the real backing entry).
Owner #3 (style): emitMetric's opaque outcome[0] char dispatch replaced with
explicit std::string_view compare (survives label renames).
Full suite: 461 cases / 57331 assertions, all green.
voidvec
added a commit
that referenced
this pull request
Aug 12, 2026
… hardening
Codex P1 (REAL, design-doc correctness fix): the design doc §5.4 wrongly
claimed 'no client write path exists today'. Verified ClientManagementService
exposes 4 runtime admin mutation paths (updateClient :280, resetClientSecret
:414, updateClientScopes :517, deleteClient :373) that bypass IClientRepository.
When cache.enabled=true these mutate Oauth2Clients directly without
invalidating authforge:cache:client:{clientId} → stale client served for up
to 300s TTL. Corrected §5.4 + added §8 risk row. Phase-1 mitigation:
cache.enabled defaults false; invalidation hooks are a tracked follow-up.
Owner #2 (REAL): cache.enabled=true + non-postgres storage was a silent no-op.
Added LOG_WARN in both the redis and memory branches so operators see the
cache is ignored.
Owner #1 (partly-fabricated API, but valid kernel): the reviewer's
fromJson()/cached.id API does not exist, but the defense-in-depth idea is
sound — deserializeClient now rejects a structurally-valid-but-empty clientId
as a miss (blank client would mask the real backing entry).
Owner #3 (style): emitMetric's opaque outcome[0] char dispatch replaced with
explicit std::string_view compare (survives label renames).
Full suite: 461 cases / 57331 assertions, all green.
voidvec
added a commit
that referenced
this pull request
Aug 12, 2026
Address Codex review feedback on PR #48: 1. target_config mislabeling: run-scenario.sh detected a deleted file (docker-compose.bench.yml) to set BENCH_TARGET_CONFIG. Changed to detect config.json.dev-backup (the actual swap marker). Verified: new result JSONs correctly show env.target_config=config.bench.json. 2. observer timing: --observe collectors were started before warmup, so their DURATION_S timeout covered warmup + only part of the measured run. Moved observer startup to AFTER warmup + reseed, immediately before the measured wrk run. Now the collection window exactly covers the measured run. Note on review comment #1 (S6 subject format): verified NOT an issue — real login tokens store numeric users.id (SessionController.cc:505), same as the benchmark seed. Both hit the findById code path. No change needed.
voidvec
added a commit
that referenced
this pull request
Aug 13, 2026
Address Codex review feedback on PR #48: 1. target_config mislabeling: run-scenario.sh detected a deleted file (docker-compose.bench.yml) to set BENCH_TARGET_CONFIG. Changed to detect config.json.dev-backup (the actual swap marker). Verified: new result JSONs correctly show env.target_config=config.bench.json. 2. observer timing: --observe collectors were started before warmup, so their DURATION_S timeout covered warmup + only part of the measured run. Moved observer startup to AFTER warmup + reseed, immediately before the measured wrk run. Now the collection window exactly covers the measured run. Note on review comment #1 (S6 subject format): verified NOT an issue — real login tokens store numeric users.id (SessionController.cc:505), same as the benchmark seed. Both hit the findById code path. No change needed.
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 20, 2026
Uniform cohorts filled with identical TTLs expire as one wave — the measured 30s-period ~800ms p99 spikes / -25% QPS dips under pool-64 (gcjitter evidence: median p99 3.28ms, max 947.8ms, 5/30 spike segs). applyTtlJitter(): uniform reduction in [0, ceil(0.15*ttl)], only-reduce (C7 upper bound intact), floor 1 (EX 0 impossible), ttl<=1 pass-through. Applied at the 4 positive-fill SET sites (access fill / introspect fill / saveAccessToken warm / client fill). Negative-cache 60s and redis-storage SETEX sites intentionally untouched. thread_local engine (IO threads). Header is src-internal — public SDK surface unchanged (api-diff clean). Bottleneck #1 of docs/performance-optimization-report.md. A/B: gcjitter before=20260820-f57b3bc (sha label only — binary identical to e30b6c5).
voidvec
added a commit
that referenced
this pull request
Aug 22, 2026
Uniform cohorts filled with identical TTLs expire as one wave — the measured 30s-period ~800ms p99 spikes / -25% QPS dips under pool-64 (gcjitter evidence: median p99 3.28ms, max 947.8ms, 5/30 spike segs). applyTtlJitter(): uniform reduction in [0, ceil(0.15*ttl)], only-reduce (C7 upper bound intact), floor 1 (EX 0 impossible), ttl<=1 pass-through. Applied at the 4 positive-fill SET sites (access fill / introspect fill / saveAccessToken warm / client fill). Negative-cache 60s and redis-storage SETEX sites intentionally untouched. thread_local engine (IO threads). Header is src-internal — public SDK surface unchanged (api-diff clean). Bottleneck #1 of docs/performance-optimization-report.md. A/B: gcjitter before=20260820-f57b3bc (sha label only — binary identical to e30b6c5).
voidvec
added a commit
that referenced
this pull request
Aug 22, 2026
Uniform cohorts filled with identical TTLs expire as one wave — the measured 30s-period ~800ms p99 spikes / -25% QPS dips under pool-64 (gcjitter evidence: median p99 3.28ms, max 947.8ms, 5/30 spike segs). applyTtlJitter(): uniform reduction in [0, ceil(0.15*ttl)], only-reduce (C7 upper bound intact), floor 1 (EX 0 impossible), ttl<=1 pass-through. Applied at the 4 positive-fill SET sites (access fill / introspect fill / saveAccessToken warm / client fill). Negative-cache 60s and redis-storage SETEX sites intentionally untouched. thread_local engine (IO threads). Header is src-internal — public SDK surface unchanged (api-diff clean). Bottleneck #1 of docs/performance-optimization-report.md. A/B: gcjitter before=20260820-f57b3bc (sha label only — binary identical to e30b6c5).
This was referenced Aug 27, 2026
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
psql/pg_isreadyand the step used a fixed sleep which is race-prone.Description
postgresql-clientto the CI apt dependencies sopsqlandpg_isreadyare available on the runner by default.sleep 5with a bounded retry loop usingpg_isready(up to 30 attempts with 2s sleeps) to wait for PostgreSQL readiness before running migrations.exit 1if PostgreSQL does not become ready within the retry window; retained execution of the SQL migration files after readiness..github/workflows/ci.ymlonly; no application source changes were made.Testing
.github/workflows/ci.ymlwere applied and the new logic appears at the expected lines.PyYAML, so that parse check could not complete (this is an environment issue, not a workflow logic error).Codex Task