Keep failed-login IPs out of the main log#760
Merged
Conversation
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>
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
Restrict the IP-bearing line to
failed_logins.logfor privacy. Todaythe same record propagates to stdout and
codex.logas well, so theclient 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 loggerWARNING (
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, orretain on its own schedule.
Implementation
not_failed_login_filterincodex/failed_login_log.py.LOG_PATHsinks incodex/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).
codex.toml.defaultto document the privacy guarantee.Test plan
make fix && make lint && make tycleanpytest tests/test_failed_login_log.py -v— 11 tests pass, 2 newSinkFilterTestsverify tagged records only reach the dedicated sink anduntagged records only reach the main sink
make test-python— 229 total, suite unaffected🤖 Generated with Claude Code