-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item14380: More proxy detection work
Add checkers for the proxy settings. Don't print detection messages unless really in bootstrap mode.
- Loading branch information
Showing
9 changed files
with
231 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
75 changes: 75 additions & 0 deletions
75
core/lib/Foswiki/Configure/Checkers/PROXY/UseForwardedHeaders.pm
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# See bottom of file for license and copyright information | ||
package Foswiki::Configure::Checkers::PROXY::UseForwardedHeaders; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Foswiki::Configure::Checker (); | ||
our @ISA = ('Foswiki::Configure::Checker'); | ||
|
||
sub check_current_value { | ||
my ( $this, $reporter ) = @_; | ||
|
||
my ( $client, $protocol, $host, $port, $proxy ) = | ||
Foswiki::Engine::_getConnectionData(1); | ||
|
||
if ($proxy) { | ||
|
||
$reporter->NOTE( | ||
"Proxy server detected. Proxy URL is $protocol://$host:$port. Local server name is $ENV{HTTP_HOST}" | ||
); | ||
|
||
if ( $Foswiki::cfg{PROXY}{UseForwardedHeaders} ) { | ||
$reporter->WARN( | ||
"Note that =ForceDefaultUrlHost= is a more secure setting for supporting a reverse proxy. " | ||
); | ||
} | ||
else { | ||
$reporter->NOTE( | ||
'This setting should be enabled if there are multiple proxy servers or there is a mix of proxied and non-proxied clients.' | ||
); | ||
} | ||
} | ||
else { | ||
if ( $Foswiki::cfg{PROXY}{UseForwardedHeaders} ) { | ||
$reporter->WARN( | ||
'You have enabled this setting, but no proxy is detected. Be sure this is what you want to do.' | ||
); | ||
} | ||
} | ||
|
||
if ( $Foswiki::cfg{ForceDefaultUrlHost} | ||
&& $Foswiki::cfg{PROXY}{UseForwardedHeaders} ) | ||
{ | ||
$reporter->ERROR( | ||
'Both ={ForceDefaultUrlHost}= and ={PROXY}{UseForwardedHeaders}= are enabled. ={PROXY}{UseForwardedHeaders}= will be ignored.' | ||
); | ||
} | ||
} | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2008-2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
Additional copyrights apply to some or all of the code in this | ||
file as follows: | ||
Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved. | ||
TWiki Contributors are listed in the AUTHORS file in the root | ||
of this distribution. NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
60 changes: 60 additions & 0 deletions
60
core/lib/Foswiki/Configure/Checkers/PermittedRedirectHostUrls.pm
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# See bottom of file for license and copyright information | ||
package Foswiki::Configure::Checkers::PermittedRedirectHostUrls; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Foswiki::Configure::Checkers::URL (); | ||
our @ISA = ('Foswiki::Configure::Checkers::URL'); | ||
|
||
sub check_current_value { | ||
my ( $this, $reporter ) = @_; | ||
|
||
foreach my $uri ( split /[,\s]/, $Foswiki::cfg{PermittedRedirectHostUrls} ) | ||
{ | ||
next unless $uri; | ||
Foswiki::Configure::Checkers::URL::checkURI( $reporter, $uri ); | ||
} | ||
|
||
# Probe the connection in bootstrap mode: | ||
my ( $client, $protocol, $host, $port, $proxy ) = | ||
Foswiki::Engine::_getConnectionData(1); | ||
$port = ( $port && $port != 80 && $port != 443 ) ? ":$port" : ''; | ||
|
||
my $detected = $protocol . '://' . $host . $port; | ||
|
||
if ( $Foswiki::cfg{DefaultUrlHost} !~ m#\Q$detected\E#i | ||
&& $Foswiki::cfg{PermittedRedirectHostUrls} !~ m#\Q$detected\E#i ) | ||
{ | ||
$reporter->WARN( | ||
"Current setting does not include =$protocol://$host$port=, and it is not the ={DefaultUrlHost}=" | ||
); | ||
} | ||
} | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2008-2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
Additional copyrights apply to some or all of the code in this | ||
file as follows: | ||
Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved. | ||
TWiki Contributors are listed in the AUTHORS file in the root | ||
of this distribution. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
Oops, something went wrong.