Merge branch '2594' into 'v2.0'

Drop double slashes in _pdata->{_url} + don't overwrite $self-portal if already set and fix (#2594)

See merge request lemonldap-ng/lemonldap-ng!249
This commit is contained in:
Yadd 2022-02-03 05:16:53 +00:00
commit 07dd22fac1
4 changed files with 8 additions and 8 deletions

View File

@ -128,7 +128,7 @@ sub _authAndTrace {
eval "require $type";
die $@ if ($@);
my ( $res, $session ) = $type->run( $req, $self->{rule} );
eval { $self->portal( $type->tsv->{portal}->() ) };
eval { $self->portal( $type->tsv->{portal}->() ) } unless $self->portal;
$self->logger->warn($@) if $@;
$req->userData($session) if ($session);
@ -201,7 +201,7 @@ sub userId {
my $userId =
$req->userData->{ $Lemonldap::NG::Handler::Main::tsv->{whatToTrace}
|| '_whatToTrace' }
|| $req->userData->{'_user'} # Fix 2377
|| $req->userData->{'_user'} # Fix 2377
|| 'anonymous';
$self->logger->debug("Returned userId: $userId");

View File

@ -100,7 +100,7 @@ sub _redirect {
$self->logger->debug(
'Add ' . $self->ipath . ', ' . $self->ipath . 'Path in keepPdata' );
push @{ $req->pdata->{keepPdata} }, $self->ipath, $self->ipath . 'Path';
$req->{urldc} = $self->conf->{portal} . '/' . $self->path;
$req->{urldc} = $self->p->buildUrl( $self->path );
$req->pdata->{_url} = encode_base64( $req->urldc, '' );
$req->pdata->{issuerTs} = time;
}
@ -128,7 +128,7 @@ sub _redirect {
$self->restoreRequest( $_[0], $ir );
$self->cleanPdata( $_[0] );
return $self->run( @_, @path );
}
}
: ()
)
]

View File

@ -115,12 +115,12 @@ ok(
count(1);
# We now should be logged in, but lost the original URL
expectRedirection( $res, "http://auth.op.com//oauth2" );
expectRedirection( $res, "http://auth.op.com/oauth2" );
my $id = expectCookie($res);
ok(
$res = $op->_get(
'//oauth2',
'/oauth2',
accept => 'text/html',
cookie => "lemonldap=$id; lemonldappdata=$pdata",
),

View File

@ -142,12 +142,12 @@ SKIP: {
);
my $id = expectCookie($res);
$pdata = expectCookie( $res, 'lemonldappdata' );
expectRedirection( $res, qr'http://auth.example.com//cas' );
expectRedirection( $res, qr'http://auth.example.com/cas' );
# Follow redirection to TOTP form
ok(
$res = $client->_get(
'//cas',
'/cas',
cookie => "lemonldap=$id; lemonldappdata=$pdata",
accept => 'text/html',
),