From 4f8830fdf67ced61c08013cee0fed1eec12a458f Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Tue, 5 Apr 2016 20:46:11 +0000 Subject: [PATCH] Macros are working now (#595) --- .../lib/Lemonldap/NG/Portal/Main/Init.pm | 12 ++++++++++-- .../lib/Lemonldap/NG/Portal/Main/Process.pm | 3 +++ .../lib/Lemonldap/NG/Portal/Main/Run.pm | 8 ++++---- lemonldap-ng-portal/t/01-AuthDemo.t | 17 +++++++++++++---- lemonldap-ng-portal/t/test-lib.pm | 1 - 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm index 58ccf9a02..f5ead354a 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm @@ -117,6 +117,12 @@ sub reloadConf { return 0; } + # Initialize persistent session DB + unless ( $self->conf->{persistentStorage} ) { + $self->conf->{persistentStorage} = $self->conf->{globalStorage}; + $self->conf->{persistentStorageOptions} = $self->conf->{globalStorageOptions}; + } + # Initialize cookie domain unless ( $self->conf->{domain} ) { $self->error('Configuration error: no domain'); @@ -193,8 +199,10 @@ sub reloadConf { $self->{"_$type"} = {}; if ( $self->conf->{$type} ) { for my $name ( sort keys %{ $self->conf->{$type} } ) { - my $sub = HANDLER->tsv->{jail}->jail_reval( - "sub{return(" . $self->conf->{$type}->{$name} . ")}" ); + my $sub = + HANDLER->tsv->{jail}->jail_reval( "sub{return(" + . HANDLER->substitute( $self->conf->{$type}->{$name} ) + . ")}" ); if ($sub) { $self->{"_$type"}->{$name} = $sub; } diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm index a85745801..5d951094b 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm @@ -143,6 +143,9 @@ sub authenticate { sub setSessionInfo { my ( $self, $req ) = @_; + # Set _user + $req->{sessionInfo}->{_user} = $req->{user}; + # Get the current user module $req->{sessionInfo}->{_auth} = $self->getModule( $req, "auth" ); $req->{sessionInfo}->{_userDB} = $self->getModule( $req, "user" ); diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm index 1b950b3c9..e227de7f5 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm @@ -227,10 +227,10 @@ sub getPersistentSession { my $ps = Lemonldap::NG::Common::Session->new( { - storageModule => $self->{persistentStorage}, - storageModuleOptions => $self->{persistentStorageOptions}, - cacheModule => $self->{localSessionStorage}, - cacheModuleOptions => $self->{localSessionStorageOptions}, + storageModule => $self->conf->{persistentStorage}, + storageModuleOptions => $self->conf->{persistentStorageOptions}, + cacheModule => $self->conf->{localSessionStorage}, + cacheModuleOptions => $self->conf->{localSessionStorageOptions}, id => $pid, force => 1, kind => "Persistent", diff --git a/lemonldap-ng-portal/t/01-AuthDemo.t b/lemonldap-ng-portal/t/01-AuthDemo.t index be59bb820..a1a209c48 100644 --- a/lemonldap-ng-portal/t/01-AuthDemo.t +++ b/lemonldap-ng-portal/t/01-AuthDemo.t @@ -6,7 +6,7 @@ require 't/test-lib.pm'; my $res; -init( { logLevel => 'debug' } ); +init( { logLevel => 'debug', useSafeJail => 1 } ); ok( $res = &client->_get('/'), 'Unauth JSON request' ); ok( $res->[0] == 401, 'Response is 401' ) or explain( $res, 401 ); @@ -40,9 +40,18 @@ ok( ), 'Auth ajax request with good url' ); -count(1); -print STDERR Dumper($res); +ok( $res->[0] == 302, 'Get redirection' ) or explain( $res, 302 ); +my %hdrs = @{ $res->[1] }; +ok( + $hdrs{Location} eq 'http://test1.example.com/', + 'Location is http://test1.example.com/' +) or explain( \%hdrs, 'Location => "http://test1.example.com/"' ); +ok( $hdrs{'Lm-Remote-User'} eq 'dwho', 'User is set' ) + or explain( \%hdrs, 'Lm-Remote-User => "dwho"' ); +count(4); -#clean_sessions(); +#print STDERR Dumper($res); + +clean_sessions(); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/test-lib.pm b/lemonldap-ng-portal/t/test-lib.pm index 5921b089d..ec50f55f4 100644 --- a/lemonldap-ng-portal/t/test-lib.pm +++ b/lemonldap-ng-portal/t/test-lib.pm @@ -80,7 +80,6 @@ has app => ( sub _get { my ( $self, $path, %args ) = @_; - print STDERR Data::Dumper::Dumper( \%args ); return $self->app->( { 'HTTP_ACCEPT' => $args{accept}