Skip to content

Extract CORS/auth/secret helpers into digest.web.security#12

Merged
DCCA merged 1 commit into
masterfrom
claude/wizardly-archimedes-a1duo9
Jun 20, 2026
Merged

Extract CORS/auth/secret helpers into digest.web.security#12
DCCA merged 1 commit into
masterfrom
claude/wizardly-archimedes-a1duo9

Conversation

@DCCA

@DCCA DCCA commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Final planned app.py extraction (after #9, #10, #11).

Change

Move the CORS, API-auth, and secret-redaction helpers + their config constants from web/app.py into a new digest.web.security module:
constants (DEFAULT_WEB_CORS_ORIGINS, DEFAULT_WEB_CORS_ORIGIN_REGEX, DEFAULT_WEB_API_AUTH_MODE, DEFAULT_WEB_API_TOKEN_HEADER, ALLOWED_WEB_API_AUTH_MODES, REDACTED_SECRET, SECRET_KEY_RE) and functions (_cors_allowed_origins, _cors_allow_origin_regex, _web_api_auth_mode, _web_api_token, _web_api_token_header, _api_auth_decision, _is_secret_key, _redact_secrets, _rehydrate_redacted_value).

  • app.py re-imports the eight route-facing helpers (CORS + auth middleware); _is_secret_key and the non-route constants stay internal to the new module.
  • os, re, and hmac are no longer imported in app.py — all their uses lived in the moved cluster.
  • test_web_security / test_web_cors import the security symbols from digest.web.security (their new owner).
  • Relocated the allowlisted detect-secrets finding (REDACTED_SECRET) in .secrets.baseline from app.py to security.py — same secret, no new finding.

web/app.py: 1875 → 1751 LOC.

Cumulative (session)

web/app.py: 2589 → 1751 LOC (−838, −32%) via four focused, re-exporting modules — schedule, run_progress, sources, security — each verbatim, no behavior change.

Verification (mirrors CI)

  • Backend: 254 tests pass; ruff check src tests: clean; bandit clean; detect-secrets clean
  • Frontend: 24 tests pass, production build succeeds

🤖 Generated with Claude Code

https://claude.ai/code/session_01GRvYFEnkge3dkDJRMmBTyh


Generated by Claude Code

Continue breaking up src/digest/web/app.py by moving the CORS, API-auth, and
secret-redaction helpers and their configuration constants into a focused
digest.web.security module (following the feedback/schedule/run_progress/sources
pattern).

- New digest.web.security holds the seven config constants and nine helpers
  (_cors_allowed_origins, _cors_allow_origin_regex, _web_api_auth_mode,
  _web_api_token, _web_api_token_header, _api_auth_decision, _is_secret_key,
  _redact_secrets, _rehydrate_redacted_value)
- app.py re-imports the eight route-facing helpers; _is_secret_key and the
  non-route constants stay internal
- os/re/hmac are no longer imported in app.py (all uses lived in the cluster)
- test_web_security/test_web_cors import the security symbols from their new
  owner module
- Relocate the allowlisted detect-secrets finding (REDACTED_SECRET) in the
  baseline from app.py to security.py (same secret, no new finding)

app.py drops from 1875 to 1751 lines; no behavior change. ruff/bandit/
detect-secrets clean and all 254 backend tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRvYFEnkge3dkDJRMmBTyh
@DCCA DCCA merged commit 72566dd into master Jun 20, 2026
4 checks passed
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