Encapsulate logic for determining if an SSL request has been made.
Refactor core modules to use that.
This commit is contained in:
parent
39127b7ec0
commit
1c9908f490
5 changed files with 23 additions and 17 deletions
|
|
@ -310,7 +310,7 @@ sub checkView {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
my ($conf, $env, $var, $http) = $self->session->quick(qw(config env var http));
|
||||
if ($conf->get("sslEnabled") && $self->get("encryptPage") && $env->get("HTTPS") ne "on" && !$env->get("SSLPROXY")) {
|
||||
if ($conf->get("sslEnabled") && $self->get("encryptPage") && ! $env->sslRequest) {
|
||||
# getUrl already changes url to https if 'encryptPage'
|
||||
$http->setRedirect($self->getUrl);
|
||||
$http->sendHeader;
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ sub toHtml {
|
|||
my $env = $self->session->env;
|
||||
my $pubKey = $self->session->setting->get('recaptchaPublicKey');
|
||||
my $server = "http://api.recaptcha.net";
|
||||
if ($env->get("HTTPS") eq "on" || $env->get("SSLPROXY")) {
|
||||
if ($env->sslRequest) {
|
||||
$server = "http://api-secure.recaptcha.net";
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ These methods are available from this package:
|
|||
|
||||
=head2 callerIsSearchSite ( )
|
||||
|
||||
returns true if the remote address matches a site which is a known indexer or spider.
|
||||
Returns true if the remote address matches a site which is a known indexer or spider.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -65,7 +65,8 @@ sub callerIsSearchSite {
|
|||
|
||||
=head2 clientIsSpider ( )
|
||||
|
||||
returns true is the client/agent is a spider/indexer or some other non-human interface
|
||||
Returns true is the client/agent is a spider/indexer or some other non-human interface, determined
|
||||
by checking the user agent against a list of known spiders.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -166,7 +167,7 @@ sub new {
|
|||
|
||||
=head2 requestNotViewed ( )
|
||||
|
||||
returns true is the client/agent is a spider/indexer or some other non-human interface
|
||||
Returns true is the client/agent is a spider/indexer or some other non-human interface
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -181,6 +182,19 @@ sub requestNotViewed {
|
|||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 sslRequest ( )
|
||||
|
||||
Returns true if a https request was made.
|
||||
|
||||
=cut
|
||||
|
||||
sub sslRequest {
|
||||
my $self = shift;
|
||||
return ($self->get('HTTPS') eq 'on' || $self->get('SSLPROXY') ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -148,11 +148,7 @@ sub extras {
|
|||
my $cdnCfg = $self->session->config->get('cdn');
|
||||
if ( $cdnCfg and $cdnCfg->{'enabled'} and $cdnCfg->{'extrasCdn'} ) {
|
||||
unless ( $path and grep $path =~ m/$_/, @{ $cdnCfg->{'extrasExclude'} } ) {
|
||||
if ($cdnCfg->{'extrasSsl'}
|
||||
and ( $self->session->env->get('HTTPS') eq 'on'
|
||||
or $self->session->env->get('SSLPROXY') )
|
||||
)
|
||||
{
|
||||
if ($cdnCfg->{'extrasSsl'} && $self->session->env->sslRequest) {
|
||||
$url = $cdnCfg->{'extrasSsl'};
|
||||
}
|
||||
else {
|
||||
|
|
@ -291,7 +287,7 @@ sub forceSecureConnection {
|
|||
my $url = shift;
|
||||
my ($conf, $env, $http) = $self->session->quick(qw(config env http));
|
||||
|
||||
if ($conf->get("sslEnabled") && $env->get("HTTPS") ne "on" && !$env->get("SSLPROXY")){
|
||||
if ($conf->get("sslEnabled") && !$env->sslRequest){
|
||||
|
||||
$url = $self->session->url->page if(! $url);
|
||||
$url = $env->get('QUERY_STRING') if(! $url);
|
||||
|
|
@ -354,7 +350,7 @@ sub getSiteURL {
|
|||
$site = $sitenames->[0];
|
||||
}
|
||||
my $proto = "http://";
|
||||
if ($self->session->env->get("HTTPS") eq "on") {
|
||||
if ($self->session->env->sslRequest) {
|
||||
$proto = "https://";
|
||||
}
|
||||
my $port = "";
|
||||
|
|
|
|||
|
|
@ -1273,11 +1273,7 @@ sub getUrl {
|
|||
and -e $self->getPath . '/.cdn' )
|
||||
{
|
||||
my $sep = '/'; # separator, if not already present trailing
|
||||
if ($cdnCfg->{'sslAlt'}
|
||||
and ( $self->session->env->get('HTTPS') eq 'on'
|
||||
or $self->session->env->get('SSLPROXY') )
|
||||
)
|
||||
{
|
||||
if ($cdnCfg->{'sslAlt'} && $self->session->env->sslRequest) {
|
||||
if ( $cdnCfg->{'sslUrl'} ) {
|
||||
substr( $cdnCfg->{'sslUrl'}, -1 ) eq '/' and $sep = '';
|
||||
$url = $cdnCfg->{'sslUrl'} . $sep . $self->getDirectoryId;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue