security: harden JWT validation and auth startup checks#27
Merged
Conversation
- SEC-C5: Raise ValueError on startup when AUTH_ENABLED=True but SUPABASE_JWT_SECRET is empty. Removes silent fallback to open access which would allow unauthenticated requests in a misconfigured prod env. Tests set AUTH_ENABLED=False via os.environ.setdefault in conftest.py. - SEC-C4: Add issuer validation to _decode_supabase_jwt(). When supabase_url is configured, pyjwt now validates iss against <supabase_url>/auth/v1, blocking tokens from other Supabase projects. - SEC-C3: Add unique=True to User.polar_customer_id, preventing duplicate billing lookups. Alembic migration 007_unique_polar_customer_id.py adds the corresponding DB constraint. - SEC-H3: /analytics/stats now accepts get_optional_user dependency and scopes results to the authenticated user's user_id when present. Unauthenticated requests get aggregate counts without query history. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marinone94
force-pushed
the
fix/auth-hardening
branch
from
March 30, 2026 22:26
cbb6228 to
db43c9b
Compare
Deploying cherry-evals with
|
| Latest commit: |
db43c9b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://29fe8f2e.cherry-evals.pages.dev |
| Branch Preview URL: | https://fix-auth-hardening.cherry-evals.pages.dev |
marinone94
added a commit
that referenced
this pull request
Mar 30, 2026
30/46 findings now fixed. All Critical and High security vulnerabilities resolved. Remaining items: GDPR endpoints, DPAs, rate limiter Redis, Langfuse instrumentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
marinone94
pushed a commit
that referenced
this pull request
Mar 30, 2026
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.
Summary
AUTH_ENABLED=TruebutSUPABASE_JWT_SECRETis empty (was silently disabling auth)iss) validation against Supabase project URLUNIQUEconstraint onpolar_customer_id+ alembic migration/analytics/statsto authenticated user viaget_optional_userFiles changed
cherry_evals/config.py— ValueError instead of silent fallbackapi/deps.py— issuer param inpyjwt.decode()db/postgres/models.py—unique=Trueonpolar_customer_idapi/routes/analytics.py— auth-aware stats endpointalembic/versions/007_unique_polar_customer_id.py— new migrationtests/conftest.py—AUTH_ENABLED=Falseenv default before importsTest plan
uv run pytestpasses (590 passed, 1 skipped)🤖 Generated with Claude Code