diff --git a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CDA.pm b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CDA.pm index 9be246b1e..63bbc9936 100644 --- a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CDA.pm +++ b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CDA.pm @@ -14,21 +14,29 @@ our @ISA = qw(Lemonldap::NG::Handler::SharedConf); sub run ($$) { my $class; ( $class, $apacheRequest ) = @_; - #my $uri = $apacheRequest->uri . ( $apacheRequest->args ? "?" . $apacheRequest->args : "" ); my $args = $apacheRequest->args; - if ($args =~ /\?($cookieName=\w+)$/o) { + if ($args =~ s/\?($cookieName=\w+)$//o) { my $str = $1; $class->lmLog( "Found a CDA id. Redirecting " - . $apacheRequest->connection->remote_ip - . " to myself with new cookie", - 'debug' + . $apacheRequest->connection->remote_ip + . " to myself with new cookie", + 'debug' ); - # TODO: https ? - $apacheRequest->headers_out->set( 'Location' => "http://".$apacheRequest->hostname ); + $apacheRequest->args ( $args ); + $apacheRequest->headers_out->set( + 'Location' => "http" + . ($https ? 's' : '') + . "://" . $apacheRequest->get_server_name() . "/" + . $apacheRequest->uri + . ( $apacheRequest->args ? "?" . $apacheRequest->args : "" ) + ); # TODO: cookie secured ? $apacheRequest->headers_out->set( 'Set-Cookie' => "$str" ); - return REDIRECT; + return REDIRECT; + } + else { + return $class->SUPER::run( $apacheRequest ); } } diff --git a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm index d2e9763c9..ddf3c2244 100644 --- a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm +++ b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm @@ -28,6 +28,8 @@ our %EXPORT_TAGS = ( lmSetHeaderOut lmSetErrHeaderOut $cookieName + $cookieSecured + $https ) ], traces => [ qw( $whatToTrace ) ], @@ -51,7 +53,7 @@ our ( $cookieName, $portal, $datas, $globalStorage, $globalStorageOptions, $localStorage, $localStorageOptions, $whatToTrace, $https, - $refLocalStorage, $safe, + $refLocalStorage, $safe, $cookieSecured, ); ########################################## @@ -323,6 +325,7 @@ sub defaultValuesInit { # Other values $cookieName = $args->{cookieName} || 'lemon'; + $cookieSecured = $args->{cookieSecured} || 0; $whatToTrace = $args->{whatToTrace} || '$uid'; $whatToTrace =~ s/\$//g; $https = $args->{https} unless defined($https);