chore: Clean up IP address tracking #2341
Merged
jnschaeffer merged 2 commits intomasterfrom Jan 27, 2026
Merged
Conversation
This commit changes the middleware order so request logging happens after the Sb-Forwarded-For IP address is added to the request context. This is necessary because otherwise request logs will always use legacy behavior for IP address tracking, as logging happens in an earlier middleware than the SBFF middleware.
This commit replaces all usage of r.RemoteAddr in Auth code with utilities.GetIPAddress (with the exception of the field's usage in GetIPAddress itself). The purpose of this commit is to ensure IP address tracking is consistent across the Auth codebase.
Pull Request Test Coverage Report for Build 21404570306Details
💛 - Coveralls |
cstockton
approved these changes
Jan 27, 2026
1012283 to
7ee9fe3
Compare
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.
What kind of change does this PR introduce?
This PR cleans up various issues and inconsistencies in IP address tracking in Auth, including:
Sb-Forwarded-Foras the canonical IP address source if the user enables itRemoteAddrvalues withutilities.GetIPAddresscallsWhat is the current behavior?
Request logs do not show the correct IP address when passing the
Sb-Forwarded-Forheader withSbForwardedForEnabledset to true. Similarly, audit logs only show the value of the request'sRemoteAddrstruct field, which is populated by thegithub.com/sebest/xffmiddleware.What is the new behavior?
IP address tracking should be consistent across all Auth code paths.