Changeset 6943


Ignore:
Timestamp:
03/26/10 17:27:33 (3 years ago)
Author:
OlivierRaginel
Message:

Item2623: Improved doc for PROXY settings (about auth), and added proxy authentication to fallback mechanism (without LWP)

Location:
trunk/core/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/lib/Foswiki.spec

    r6932 r6943  
    11791179# Some environments require outbound HTTP traffic to go through a proxy 
    11801180# server. (e.g. http://proxy.your.company). 
    1181 # <b>CAUTION</b> This setting can be overridden by a %PROXYHOST% setting 
    1182 # in SitePreferences. Make sure you delete the setting from there. 
     1181# <b>CAUTION</b> This setting can be overridden by a PROXYHOST setting 
     1182# in SitePreferences. Make sure you delete the setting from there if 
     1183# you are using a SitePreferences topic from a previous release of Foswiki. 
     1184# If your proxy requires authentication, simply put it in the URL, as in: 
     1185# http://username:password@proxy.your.company. 
    11831186$Foswiki::cfg{PROXY}{HOST} = ''; 
    11841187 
     
    11861189# Some environments require outbound HTTP traffic to go through a proxy 
    11871190# server. Set the port number here (e.g: 8080). 
    1188 # <b>CAUTION</b> This setting can be overridden by a %PROXYPORT% setting 
    1189 # in SitePreferences. Make sure you delete the setting from there. 
     1191# <b>CAUTION</b> This setting can be overridden by a PROXYPORT setting 
     1192# in SitePreferences. Make sure you delete the setting from there if you 
     1193# are using a SitePreferences topic from a previous release of Foswiki. 
    11901194$Foswiki::cfg{PROXY}{PORT} = ''; 
    11911195 
  • trunk/core/lib/Foswiki/Net.pm

    r6761 r6943  
    165165            $proxyPort = $prefs->getPreference('PROXYPORT'); 
    166166        } 
    167         $proxyHost ||= $Foswiki::cfg{PROXY}{HOST}; 
    168         $proxyPort ||= $Foswiki::cfg{PROXY}{PORT}; 
     167 
     168        # Do not use || so user can disable proxy using preferences 
     169        $proxyHost = $Foswiki::cfg{PROXY}{HOST} unless defined $proxyHost; 
     170        $proxyPort = $Foswiki::cfg{PROXY}{PORT} unless defined $proxyPort; 
    169171        if ( $proxyHost && $proxyPort ) { 
     172            my ( $proxyUser, $proxyPass ); 
     173            if ( $proxyHost =~ m#^http://(?:(.*?)(?::(.*?))?@)?(.*)(?::(\d+))?/*# ) { 
     174                $proxyUser = $1; 
     175                $proxyPass = $2; 
     176                $proxyHost = $3; 
     177                $proxyPort = $4 if defined $4; 
     178            } else { 
     179                require Foswiki::Net::HTTPResponse; 
     180                return new Foswiki::Net::HTTPResponse( 
     181                    "Proxy settings are invalid, check configure ($proxyHost)"); 
     182            } 
    170183            $req  = "GET http://$host:$port$url HTTP/1.0\r\n"; 
    171184            $host = $proxyHost; 
    172185            $port = $proxyPort; 
     186            if ($proxyUser) { 
     187                require MIME::Base64; 
     188                import MIME::Base64(); 
     189                my $base64 = encode_base64( "$proxyUser:$proxyPass", "\r\n" ); 
     190                $req .= "Proxy-Authorization: Basic $base64"; 
     191            } 
    173192        } 
    174193 
Note: See TracChangeset for help on using the changeset viewer.