Skip to content

Keep failed-login IPs out of the main log#760

Merged
ajslater merged 1 commit into
developfrom
claude/failed-login-not-in-main-log
May 10, 2026
Merged

Keep failed-login IPs out of the main log#760
ajslater merged 1 commit into
developfrom
claude/failed-login-not-in-main-log

Conversation

@ajslater
Copy link
Copy Markdown
Owner

Summary

Restrict the IP-bearing line to failed_logins.log for privacy. Today
the same record propagates to stdout and codex.log as well, so the
client IP ends up duplicated across logs that may have different
retention, access, or forwarding rules.

After this change:

  • failed_logins.log: Failed login from <ip> user=<name> (unchanged)
  • codex.log / stdout: still receives Django's own request logger
    WARNING (Unauthorized: /api/v3/auth/login/, Forbidden: /opds/...)
    so the failure is visible, just without the IP

Concentrating PII (IP + username) in one file makes the privacy story
easier to reason about: one file to chmod, forward to a SIEM, or
retain on its own schedule.

Implementation

  • Add a sibling not_failed_login_filter in codex/failed_login_log.py.
  • Attach it to the stdout and LOG_PATH sinks in codex/startup/loguru.py,
    only when the feature is enabled (when off, no records carry the tag
    and the inverse filter would be a no-op anyway).
  • Update README + codex.toml.default to document the privacy guarantee.

Test plan

  • make fix && make lint && make ty clean
  • pytest tests/test_failed_login_log.py -v — 11 tests pass, 2 new
    SinkFilterTests verify tagged records only reach the dedicated sink and
    untagged records only reach the main sink
  • make test-python — 229 total, suite unaffected

🤖 Generated with Claude Code

Add not_failed_login_filter and attach it to the stdout / codex.log
sinks so the IP-bearing line is written only to failed_logins.log.
Django's own request logger still emits a bare WARNING for each
failed attempt ("Unauthorized: /api/v3/auth/login/" etc.) so the
failure remains visible in codex.log without exposing the client IP.

Concentrating IP + username in one file makes the privacy story
easier to reason about: one file to chmod, forward to a SIEM, or
retain on its own schedule.

The inverse filter is only attached when the feature is enabled —
when disabled, no records carry the tag and the filter would be a
no-op anyway.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ajslater ajslater merged commit 37b51ca into develop May 10, 2026
3 checks passed
@ajslater ajslater deleted the claude/failed-login-not-in-main-log branch May 11, 2026 00:09
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.

1 participant