Manage maintenance mode in Handler (#342)
This commit is contained in:
parent
eb7e937ab3
commit
3552b4d70c
|
@ -11,6 +11,7 @@ PerlRequire __HANDLER__
|
|||
# Common error page and security parameters
|
||||
ErrorDocument 403 http://auth.__DNSDOMAIN__/?lmError=403
|
||||
ErrorDocument 500 http://auth.__DNSDOMAIN__/?lmError=500
|
||||
ErrorDocument 503 http://auth.__DNSDOMAIN__/?lmError=503
|
||||
|
||||
# Sample application
|
||||
<VirtualHost __VHOSTLISTEN__>
|
||||
|
|
|
@ -12,6 +12,7 @@ PerlRequire __HANDLER__
|
|||
# Common error page and security parameters
|
||||
ErrorDocument 403 http://auth.__DNSDOMAIN__/?lmError=403
|
||||
ErrorDocument 500 http://auth.__DNSDOMAIN__/?lmError=500
|
||||
ErrorDocument 503 http://auth.__DNSDOMAIN__/?lmError=503
|
||||
|
||||
# Sample application
|
||||
<VirtualHost __VHOSTLISTEN__>
|
||||
|
|
|
@ -24,8 +24,9 @@ use Lemonldap::NG::Common::Crypto;
|
|||
require POSIX;
|
||||
use CGI::Util 'expires';
|
||||
use constant SAFEWRAP => ( Safe->can("wrap_code_ref") ? 1 : 0 );
|
||||
use constant UNPROTECT => 1;
|
||||
use constant SKIP => 2;
|
||||
use constant UNPROTECT => 1;
|
||||
use constant SKIP => 2;
|
||||
use constant MAINTENANCE_CODE => 503;
|
||||
|
||||
#inherits Cache::Cache
|
||||
#inherits Apache::Session
|
||||
|
@ -935,6 +936,20 @@ sub run ($$) {
|
|||
return DECLINED unless ( $apacheRequest->is_initial_req );
|
||||
my $args = $apacheRequest->args;
|
||||
|
||||
# Direct return if maintenance mode is active
|
||||
if ( $class->checkMaintenanceMode() ) {
|
||||
|
||||
if ($useRedirectOnError) {
|
||||
$class->lmLog( "Got to portal with maintenance error code",
|
||||
'debug' );
|
||||
return $class->goToPortal( '/', 'lmError=' . MAINTENANCE_CODE );
|
||||
}
|
||||
else {
|
||||
$class->lmLog( "Return maintenance error code", 'debug' );
|
||||
return MAINTENANCE_CODE;
|
||||
}
|
||||
}
|
||||
|
||||
# Cross domain authentication
|
||||
if ( $cda and $args =~ s/[\?&]?($cookieName=\w+)$//oi ) {
|
||||
my $str = $1;
|
||||
|
@ -1037,6 +1052,20 @@ sub run ($$) {
|
|||
}
|
||||
}
|
||||
|
||||
## @rmethod protected boolean checkMaintenanceMode
|
||||
# Check if we are in maintenance mode
|
||||
# @return true if maintenance mode
|
||||
sub checkMaintenanceMode {
|
||||
my ($class) = splice @_;
|
||||
|
||||
if ($maintenance) {
|
||||
$class->lmLog( "Maintenance mode activated", 'debug' );
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
|
|
@ -314,6 +314,25 @@ sub transformUri {
|
|||
OK;
|
||||
}
|
||||
|
||||
## @rmethod protected boolean checkMaintenanceMode
|
||||
# Check if we are in maintenance mode
|
||||
# @return true if maintenance mode
|
||||
sub checkMaintenanceMode {
|
||||
my ($class) = splice @_;
|
||||
my $vhost = $apacheRequest->hostname;
|
||||
my $_maintenance =
|
||||
( defined $maintenance->{$vhost} )
|
||||
? $maintenance->{$vhost}
|
||||
: $maintenance->{_};
|
||||
|
||||
if ($_maintenance) {
|
||||
$class->lmLog( "Maintenance mode activated", 'debug' );
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
<TMPL_IF ERROR500>
|
||||
<h3><lang en="Error occurs on the server" fr="Une erreur est survenue sur le serveur" /></h3>
|
||||
</TMPL_IF>
|
||||
<TMPL_IF ERROR503>
|
||||
<h3><lang en="This application is in maintenance, please try to connect later" fr="Cette application est en maintenance, merci de réessayer plus tard" /></h3>
|
||||
</TMPL_IF>
|
||||
<TMPL_IF URL>
|
||||
<h3>
|
||||
<lang en="You were redirect from " fr="Vous avez été redirigé depuis " />
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
<div class="message negative"><ul><li><lang en="Error occurs on the server" fr="Une erreur est survenue sur le serveur" /></li></ul></div>
|
||||
</TMPL_IF>
|
||||
|
||||
<TMPL_IF ERROR503>
|
||||
<div class="message warning"><ul><li><lang en="This application is in maintenance, please try to connect later" fr="Cette application est en maintenance, merci de réessayer plus tard" /></li></ul></div>
|
||||
</TMPL_IF>
|
||||
|
||||
<div class="loginlogo"></div>
|
||||
|
||||
<div id="error">
|
||||
|
|
|
@ -30,6 +30,7 @@ sub display {
|
|||
# Error code
|
||||
my $error500 = 1 if ( $http_error eq "500" );
|
||||
my $error403 = 1 if ( $http_error eq "403" );
|
||||
my $error503 = 1 if ( $http_error eq "503" );
|
||||
|
||||
# Check URL
|
||||
$self->_sub('controlUrlOrigin');
|
||||
|
@ -40,6 +41,7 @@ sub display {
|
|||
URL => $self->{urldc},
|
||||
ERROR403 => $error403,
|
||||
ERROR500 => $error500,
|
||||
ERROR503 => $error503,
|
||||
);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user