Merge remote-tracking branch 'max/fix-redir' into v2.0

This commit is contained in:
Xavier Guimard 2019-02-03 22:48:43 +01:00
commit c5a3687040
15 changed files with 99 additions and 51 deletions

View File

@ -66,6 +66,7 @@ sub defaultValues {
'handlerInternalCache' => 15,
'hiddenAttributes' => '_password',
'httpOnly' => 1,
'https' => -1,
'infoFormMethod' => 'get',
'issuerDBCASPath' => '^/cas/',
'issuerDBCASRule' => 1,
@ -173,6 +174,7 @@ sub defaultValues {
'pamService' => 'login',
'passwordDB' => 'Demo',
'passwordResetAllowedRetries' => 3,
'port' => -1,
'portal' => 'http://auth.example.com/',
'portalAntiFrame' => 1,
'portalCheckLogins' => 1,

View File

@ -204,7 +204,6 @@ sub defaultValuesInit {
$class->tsv->{cipher} = Lemonldap::NG::Common::Crypto->new( $conf->{key} );
foreach my $opt (qw(https port maintenance)) {
next unless defined $conf->{$opt};
# Record default value in key '_'
$class->tsv->{$opt} = { _ => $conf->{$opt} };
@ -216,7 +215,7 @@ sub defaultValuesInit {
$conf->{vhostOptions}->{$vhost} ||= {};
my $val = $conf->{vhostOptions}->{$vhost}->{$name};
# Keep default value if $val is negative
# Keep global value if $val is negative
if ( defined $val and $val >= 0 ) {
$class->logger->debug(
"Options $opt for vhost $vhost: $val");

View File

@ -402,12 +402,8 @@ sub fetchId {
my ( $class, $req ) = @_;
my $t = $req->{env}->{HTTP_COOKIE} or return 0;
my $vhost = $class->resolveAlias($req);
my $lookForHttpCookie = (
$class->tsv->{securedCookie} =~ /^(2|3)$/
and !( defined( $class->tsv->{https}->{$vhost} ) )
? $class->tsv->{https}->{$vhost}
: $class->tsv->{https}->{_}
);
my $lookForHttpCookie = ( $class->tsv->{securedCookie} =~ /^(2|3)$/
and not $class->_isHttps( $req, $vhost ) );
my $cn = $class->tsv->{cookieName};
my $value
= $lookForHttpCookie
@ -535,23 +531,67 @@ sub retrieveSession {
}
}
## @cmethod private int _getPort(string s)
# Returns the port on which this vhost is accessed
# @param $s VHost name
# @return PORT
sub _getPort {
my ( $class, $req, $vhost ) = @_;
if ( defined $class->tsv->{port}->{$vhost}
and ( $class->tsv->{port}->{$vhost} > 0 ) )
{
return $class->tsv->{port}->{$vhost};
}
else {
if ( defined $class->tsv->{port}->{_}
and ( $class->tsv->{port}->{_} > 0 ) )
{
return $class->tsv->{port}->{_};
}
else {
return $req->{env}->{SERVER_PORT};
}
}
}
## @cmethod private boot _isHttps(string s)
# Returns whether this VHost should he accessed
# via HTTPS
# @param $s VHost name
# @return RUE if the vhost should be accessed over HTTPS
sub _isHttps {
my ( $class, $req, $vhost ) = @_;
if ( defined $class->tsv->{https}->{$vhost}
and ( $class->tsv->{https}->{$vhost} > -1 ) )
{
return $class->tsv->{https}->{$vhost};
}
else {
if ( defined $class->tsv->{https}->{_}
and ( $class->tsv->{https}->{_} > -1 ) )
{
return $class->tsv->{https}->{_};
}
else {
return ( uc( $req->{env}->{HTTPS} ) eq "ON" );
}
}
}
## @cmethod private string _buildUrl(string s)
# Transform /<s> into http(s?)://<host>:<port>/s
# @param $s path
# @return URL
sub _buildUrl {
my ( $class, $req, $s ) = @_;
my $realvhost = $req->{env}->{HTTP_HOST};
my $vhost = $class->resolveAlias($req);
my $_https = (
defined( $class->tsv->{https}->{$vhost} )
? $class->tsv->{https}->{$vhost}
: $class->tsv->{https}->{_}
);
my $portString
= $class->tsv->{port}->{$vhost}
|| $class->tsv->{port}->{_}
|| $req->{env}->{SERVER_PORT};
my $realvhost = $req->{env}->{HTTP_HOST};
my $vhost = $class->resolveAlias($req);
my $_https = $class->_isHttps( $req, $vhost );
my $portString = $class->_getPort( $req, $vhost );
$portString = (
( $realvhost =~ /:\d+/ )
or ( $_https && $portString == 443 )

View File

@ -1180,8 +1180,8 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
'type' => 'bool'
},
'https' => {
'default' => 0,
'type' => 'bool'
'default' => -1,
'type' => 'trool'
},
'infoFormMethod' => {
'default' => 'get',
@ -2155,7 +2155,8 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
'type' => 'keyTextContainer'
},
'port' => {
'type' => 'int'
'default' => -1,
'type' => 'int'
},
'portal' => {
'default' => 'http://auth.example.com/',

View File

@ -293,8 +293,8 @@ sub attributes {
flags => 'hmp',
},
https => {
default => 0,
type => 'bool',
default => -1,
type => 'trool',
documentation => 'Use HTTPS for redirection from portal',
flags => 'h',
},
@ -306,6 +306,7 @@ sub attributes {
documentation => 'HTTP method for info page form',
},
port => {
default => -1,
type => 'int',
documentation => 'Force port in redirection',
flags => 'h',

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.12.7
// Generated by CoffeeScript 1.12.8
/*
LemonLDAP::NG Manager client

File diff suppressed because one or more lines are too long

View File

@ -1417,11 +1417,12 @@
"type": "simpleInputContainer"
}, {
"_nodes": [{
"default": 0,
"default": -1,
"id": "https",
"title": "https",
"type": "bool"
"type": "trool"
}, {
"default": -1,
"id": "port",
"title": "port",
"type": "int"

View File

@ -1597,16 +1597,17 @@
"title": "redirection",
"type": "simpleInputContainer",
"nodes": [{
"default": 0,
"default": -1,
"id": "https",
"title": "https",
"type": "bool",
"data": 0
"type": "trool",
"data": -1
}, {
"default": -1,
"id": "port",
"title": "port",
"type": "int",
"data": null
"data": -1
}, {
"default": 0,
"id": "useRedirectOnForbidden",

View File

@ -1608,16 +1608,17 @@
"title": "redirection",
"type": "simpleInputContainer",
"nodes": [{
"default": 0,
"id": "https",
"title": "https",
"type": "bool",
"data": 0
"type": "trool",
"default": -1,
"data": -1
}, {
"id": "port",
"title": "port",
"default": -1,
"type": "int",
"data": null
"data": -1
}, {
"default": 0,
"id": "useRedirectOnForbidden",

View File

@ -1611,13 +1611,15 @@
"default": 0,
"id": "https",
"title": "https",
"type": "bool",
"data": 0
"type": "trool",
"default": -1,
"data": -1
}, {
"id": "port",
"title": "port",
"type": "int",
"data": null
"default": -1,
"data": -1
}, {
"default": 0,
"id": "useRedirectOnForbidden",

View File

@ -1590,13 +1590,15 @@
"default": 0,
"id": "https",
"title": "https",
"type": "bool",
"data": 0
"default": -1,
"type": "trool",
"data": -1
}, {
"id": "port",
"default": -1,
"title": "port",
"type": "int",
"data": null
"data": -1
}, {
"default": 0,
"id": "useRedirectOnForbidden",

View File

@ -2249,13 +2249,14 @@
},
{
"_nodes": [{
"default": 0,
"id": "https",
"default": -1,
"title": "https",
"type": "bool"
"type": "trool"
},
{
"id": "port",
"default": -1,
"title": "port",
"type": "int"
},

View File

@ -199,12 +199,9 @@ sub send_mail {
Subject => $subject,
Type => 'TEXT',
Data => $body,
Type => 'text/plain',
Charset => $self->charset,
);
# Manage content type and charset
$message->attr( "content-type" => "text/plain" );
$message->attr( "content-type.charset" => $self->charset );
}
# Send the mail

View File

@ -326,7 +326,7 @@ sub _reset {
if ( $self->conf->{mailConfirmBody} ) {
# We use a specific text message, no html
$body = $self->{mailConfirmBody};
$body = $self->conf->{mailConfirmBody};
}
else {
@ -464,7 +464,7 @@ sub changePwd {
if ( $self->conf->{mailBody} ) {
# We use a specific text message, no html
$body = $self->{mailBody};
$body = $self->conf->{mailBody};
}
else {