Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging of users IP address when RT is hosted behind a reverse proxy #211

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/RT/Authen/ExternalAuth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ sub DoAuth {
$RT::Logger->info( "Successful login for",
$session->{'CurrentUser'}->Name,
"from",
( RT::Interface::Web::RequestENV('REMOTE_ADDR') || 'UNKNOWN') );
( RT::Interface::Web::RequestENV('HTTP_X_FORWARDED_FOR')
|| RT::Interface::Web::RequestENV('REMOTE_ADDR')
|| 'UNKNOWN') );
# Do not delete the session. User stays logged in and
# autohandler will not check the password again

Expand Down
2 changes: 1 addition & 1 deletion lib/RT/Interface/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ sub AttemptPasswordAuthentication {

my $m = $HTML::Mason::Commands::m;

my $remote_addr = RequestENV('REMOTE_ADDR');
my $remote_addr = RequestENV('HTTP_X_FORWARDED_FOR') || RequestENV('REMOTE_ADDR');
unless ( $user_obj->id && $user_obj->IsPassword( $ARGS->{pass} ) ) {
$RT::Logger->error("FAILED LOGIN for @{[$ARGS->{user}]} from $remote_addr");
$m->callback( %$ARGS, CallbackName => 'FailedLogin', CallbackPage => '/autohandler' );
Expand Down