Commit c912ab2d authored by Yadd's avatar Yadd

#5 is fixed: Now we have to set vhostHttps in manager

parent de64f48d
......@@ -577,7 +577,7 @@ debian-diff:
@$(DIFF) lemonldap-ng-portal/example/cdc.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/portal/cdc.pl ||true
@# Handler
@$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Handler ||true
@$(DIFF) lemonldap-ng-portal/example/scripts/purgeLocalCache $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/purgeLocalCache ||true
@$(DIFF) lemonldap-ng-handler/example/scripts/purgeLocalCache $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/purgeLocalCache ||true
@# Common
@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Common ||true
@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common.pm $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Common.pm ||true
......@@ -607,7 +607,7 @@ default-diff:
@$(DIFF) lemonldap-ng-handler/example/MyHandler.pm $(LMPREFIX)/handler/MyHandler.pm ||true
@$(DIFF) lemonldap-ng-handler/example/MyHandlerZimbra.pm $(LMPREFIX)/handler/MyHandlerZimbra.pm ||true
@$(DIFF) lemonldap-ng-handler/example/MyHandlerSympa.pm $(LMPREFIX)/handler/MyHandlerSympa.pm ||true
@$(DIFF) lemonldap-ng-portal/example/scripts/purgeLocalCache $(LMPREFIX)/bin/purgeLocalCache ||true
@$(DIFF) lemonldap-ng-handler/example/scripts/purgeLocalCache $(LMPREFIX)/bin/purgeLocalCache ||true
@# Common
@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common /usr/local/share/perl/5.10.0/Lemonldap/NG/Common ||true
@$(DIFF) lemonldap-ng-common/lib/Lemonldap/NG/Common.pm /usr/local/share/perl/5.10.0/Lemonldap/NG/Common.pm ||true
......
......@@ -956,11 +956,15 @@ sub hideCookie {
# Encode URl in the format used by Lemonldap::NG::Portal for redirections.
sub encodeUrl {
my ( $class, $url ) = splice @_;
my $u = $url;
$url = $class->_buildUrl($url) if ( $url !~ m#^https?://# );
return encode_base64( $u, '' );
$class->lmLog( $url, 'error' );
return encode_base64( $url, '' );
}
## @method private string _buildUrl(string s)
# Transform /<s> into http(s?)://<host>:<port>/s
# @param $s path
# @return URL
sub _buildUrl {
my ( $class, $s ) = splice @_;
my $portString = $port || $apacheRequest->get_server_port();
......
......@@ -13,7 +13,21 @@ use constant SAFEWRAP => ( Safe->can("wrap_code_ref") ? 1 : 0 );
our $VERSION = '0.55';
## @cmethod void locationRulesInit(hashRef args)
## @imethod protected void defaultValuesInit(hashRef args)
# Set default values for non-customized variables
# @param $args reference to the configuration hash
sub defaultValuesInit {
my ( $class, $args ) = splice @_;
$args->{https} = { _ => $args->{https} } unless ( ref( $args->{https} ) );
if ( $args->{vhostHttps} ) {
while ( my ( $k, $v ) = each( %{ $args->{vhostHttps} } ) ) {
$args->{https}->{$k} = $v;
}
}
$class->Lemonldap::NG::Handler::Simple::defaultValuesInit($args);
}
## @imethod void locationRulesInit(hashRef args)
# Compile rules.
# Rules are stored in $args->{locationRules}->{&lt;virtualhost&gt;} that contains
# regexp=>test expressions where :
......@@ -56,7 +70,7 @@ sub locationRulesInit {
1;
}
## @cmethod void forgeHeadersInit(hashRef args)
## @imethod void forgeHeadersInit(hashRef args)
# Create the &$forgeHeaders->{&lt;virtualhost&gt;} subroutines used to insert
# headers into the HTTP request.
# @param $args reference to the configuration hash
......@@ -90,7 +104,7 @@ sub forgeHeadersInit {
1;
}
## @cmethod void sendHeaders()
## @rmethod void sendHeaders()
# Launch function compiled by forgeHeadersInit() for the current virtual host
sub sendHeaders {
my $class = shift;
......@@ -117,7 +131,7 @@ sub isProtected {
return $defaultProtection->{$vhost};
}
## @cmethod boolean grant()
## @rmethod boolean grant()
# Grant or refuse client using compiled regexp and functions
# @return True if the user is granted to access to the current URL
sub grant {
......@@ -242,6 +256,36 @@ sub transformUri {
OK;
}
## @cmethod private string _buildUrl(string s)
# Transform /<s> into http(s?)://<host>:<port>/s
# @param $s path
# @return URL
sub _buildUrl {
my ( $class, $s ) = splice @_;
my $portString = $port || $apacheRequest->get_server_port();
my $vhost = $apacheRequest->hostname;
my $_https =
( defined( $https->{$vhost} ) ? $https->{$vhost} : $https->{_} );
$portString =
( $_https && $portString == 443 ) ? ''
: ( !$_https && $portString == 80 ) ? ''
: ':' . $portString;
$class->lmLog(
"http"
. ( $_https ? "s" : "" ) . "://"
. $apacheRequest->get_server_name()
. $portString
. $s,
'error'
);
return
"http"
. ( $_https ? "s" : "" ) . "://"
. $apacheRequest->get_server_name()
. $portString
. $s;
}
1;
__END__
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment