Skip to content
Snippets Groups Projects
Commit d1590338 authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

factorisation

parent 937d5d91
Branches
Tags
No related merge requests found
...@@ -403,9 +403,7 @@ sub req_complete_challenge { ...@@ -403,9 +403,7 @@ sub req_complete_challenge {
PRE_CHOMP => CHOMP_ONE, PRE_CHOMP => CHOMP_ONE,
INCLUDE_PATH => $templates_dir INCLUDE_PATH => $templates_dir
}); });
my $source_ip = $ENV{HTTP_X_FORWARDED_FOR} ? my $source_ip = get_source_address();
(split(/, /, $ENV{HTTP_X_FORWARDED_FOR}))[0] :
$ENV{REMOTE_ADDR};
my $user = my $user =
$ENV{'HTTP_DISPLAYNAME'} ? $ENV{'HTTP_DISPLAYNAME'} : $ENV{'HTTP_DISPLAYNAME'} ? $ENV{'HTTP_DISPLAYNAME'} :
$ENV{'displayName'} ? $ENV{'displayName'} : $ENV{'displayName'} ? $ENV{'displayName'} :
...@@ -709,9 +707,7 @@ sub req_status { ...@@ -709,9 +707,7 @@ sub req_status {
my ($self) = @_; my ($self) = @_;
Net::IP->require(); Net::IP->require();
my $source_ip_string = $ENV{HTTP_X_FORWARDED_FOR} ? my $source_ip_string = get_source_address();
(split(/, /, $ENV{HTTP_X_FORWARDED_FOR}))[0] :
$ENV{REMOTE_ADDR};
my $source_ip = Net::IP->new($source_ip_string); my $source_ip = Net::IP->new($source_ip_string);
my @allowed_ips_strings = $self->{configuration}->{status}->{allow} ? my @allowed_ips_strings = $self->{configuration}->{status}->{allow} ?
split(/, */, $self->{configuration}->{status}->{allow}) : (); split(/, */, $self->{configuration}->{status}->{allow}) : ();
...@@ -821,4 +817,10 @@ sub check_authentication { ...@@ -821,4 +817,10 @@ sub check_authentication {
) if !$ENV{'HTTP_DISPLAYNAME'}; ) if !$ENV{'HTTP_DISPLAYNAME'};
} }
sub get_source_address {
return $ENV{HTTP_X_FORWARDED_FOR} ?
(split(/, /, $ENV{HTTP_X_FORWARDED_FOR}))[0] :
$ENV{REMOTE_ADDR};
}
1; 1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment