Use pdata in Choice (#1461)

This commit is contained in:
Xavier Guimard 2018-07-05 22:05:24 +02:00
parent 7b1fd1eae7
commit 1a6f717dfc
13 changed files with 10 additions and 76 deletions

View File

@ -150,12 +150,6 @@ sub extractFormInfo {
$local_url .= ( $local_url =~ /\?/ ? '&' : '?' ) $local_url .= ( $local_url =~ /\?/ ? '&' : '?' )
. build_urlencoded( url => $req->datas->{_url} ); . build_urlencoded( url => $req->datas->{_url} );
} }
if ( $self->conf->{authChoiceParam}
and my $tmp = $req->param( $self->conf->{authChoiceParam} ) )
{
$local_url .= ( $local_url =~ /\?/ ? '&' : '?' )
. build_urlencoded( $self->conf->{authChoiceParam} => $tmp );
}
# Forward hidden fields # Forward hidden fields
if ( $req->{portalHiddenFormValues} if ( $req->{portalHiddenFormValues}

View File

@ -161,17 +161,6 @@ sub fb {
my $fb; my $fb;
my $sep = '?'; my $sep = '?';
my $ret = $conf->{portal}; my $ret = $conf->{portal};
my %prm;
foreach my $v ( [ $req->datas->{_url}, "url" ],
[ $req->param( $conf->{authChoiceParam} ), $conf->{authChoiceParam} ] )
{
if ( $v->[0] ) {
$prm{ $v->[1] } = $v->[0];
}
}
if (%prm) {
$ret .= '?' . build_urlencoded(%prm);
}
eval { eval {
$fb = Net::Facebook::Oauth2->new( $fb = Net::Facebook::Oauth2->new(

View File

@ -77,13 +77,6 @@ sub extractFormInfo {
# Build redirect_uri # Build redirect_uri
my $callback_url = $self->conf->{portal}; my $callback_url = $self->conf->{portal};
# Use authChoiceParam in redirect URL
if ( $req->param( $self->conf->{authChoiceParam} ) ) {
$callback_url .= ( $callback_url =~ /\?/ ? '&' : '?' );
$callback_url .= build_urlencoded( $self->conf->{authChoiceParam} =>
$req->param( $self->conf->{authChoiceParam} ) );
}
# Check return values # Check return values
my $error = $req->param("error"); my $error = $req->param("error");
my $code = $req->param("code"); my $code = $req->param("code");

View File

@ -151,16 +151,7 @@ sub extractFormInfo {
my $check_url = $claimed_identity->check_url( my $check_url = $claimed_identity->check_url(
return_to => $self->conf->{portal} return_to => $self->conf->{portal}
. '?openid=1&' . '?openid=1&'
. build_urlencoded( . ( $req->datas->{_url} ? build_urlencoded( url => $req->datas->{_url} ) : '' ),
( $req->datas->{_url} ? ( url => $req->datas->{_url} ) : () ),
(
$self->conf->{authChoiceParam}
and $req->param( $self->conf->{authChoiceParam} )
? ( $self->conf->{authChoiceParam} =>
$req->param( $self->conf->{authChoiceParam} ) )
: ()
)
),
trust_root => $self->conf->{portal}, trust_root => $self->conf->{portal},
delayed_return => 1, delayed_return => 1,
); );

View File

@ -87,10 +87,6 @@ sub extractFormInfo {
if ( $req->datas->{_url} ) { if ( $req->datas->{_url} ) {
$prm{url} = $req->datas->{_url}; $prm{url} = $req->datas->{_url};
} }
if ( $req->param( $self->conf->{authChoiceParam} ) ) {
$prm{ $self->conf->{authChoiceParam} } =
$req->param( $self->conf->{authChoiceParam} );
}
# Forward hidden fields # Forward hidden fields
if ( exists $req->{portalHiddenFormValues} ) { if ( exists $req->{portalHiddenFormValues} ) {

View File

@ -352,12 +352,6 @@ sub validateST {
# TODO: @coudot: why die here without any message ? # TODO: @coudot: why die here without any message ?
die if ( $proxy_url =~ /casProxy=1/ ); die if ( $proxy_url =~ /casProxy=1/ );
$proxy_url .= ( $proxy_url =~ /\?/ ? '&' : '?' ) . 'casProxy=1'; $proxy_url .= ( $proxy_url =~ /\?/ ? '&' : '?' ) . 'casProxy=1';
if ( $self->conf->{authChoiceParam}
and my $tmp = $req->param( $self->conf->{authChoiceParam} ) )
{
$proxy_url .=
'&' . build_urlencoded( $self->conf->{authChoiceParam} => $tmp );
}
$self->logger->debug("CAS Proxy URL: $proxy_url"); $self->logger->debug("CAS Proxy URL: $proxy_url");

View File

@ -99,6 +99,7 @@ sub checkChoice {
$name ||= $name ||=
$req->userData->{_choice} $req->userData->{_choice}
|| $req->sessionInfo->{_choice} || $req->sessionInfo->{_choice}
|| $req->pdata->{_choice}
|| $req->param( $self->conf->{authChoiceParam} ) || $req->param( $self->conf->{authChoiceParam} )
or return 0; or return 0;
unless ( defined $self->modules->{$name} ) { unless ( defined $self->modules->{$name} ) {
@ -107,8 +108,7 @@ sub checkChoice {
} }
# Store choice if module loops # Store choice if module loops
$self->p->setHiddenFormValue( $req, $self->conf->{authChoiceParam}, $req->pdata->{_choice} = $name;
$name, '', 0 );
return $name if ( $req->datas->{ "enabledMods" . $self->type } ); return $name if ( $req->datas->{ "enabledMods" . $self->type } );
$req->sessionInfo->{_choice} = $name; $req->sessionInfo->{_choice} = $name;
$req->datas->{ "enabledMods" . $self->type } = [ $self->modules->{$name} ]; $req->datas->{ "enabledMods" . $self->type } = [ $self->modules->{$name} ];

View File

@ -227,15 +227,6 @@ sub getCallbackUri {
? '&' . $callback_get_param . '=1' ? '&' . $callback_get_param . '=1'
: '?' . $callback_get_param . '=1'; : '?' . $callback_get_param . '=1';
# Use authChoiceParam in redirect URL
if ( $self->conf->{authChoiceParam}
and $req->param( $self->conf->{authChoiceParam} ) )
{
$callback_uri .= '&'
. build_urlencoded( $self->{authChoiceParam} =>
$req->param( $self->conf->{authChoiceParam} ) );
}
$self->logger->debug("OpenIDConnect Callback URI: $callback_uri"); $self->logger->debug("OpenIDConnect Callback URI: $callback_uri");
return $callback_uri; return $callback_uri;
} }

View File

@ -88,7 +88,8 @@ sub AUTOLOAD {
if ( $self->p->can($sub) ) { if ( $self->p->can($sub) ) {
return $self->p->$sub(@_); return $self->p->$sub(@_);
} }
die "Unknown method $sub"; require Carp;
Carp::confess "Unknown method $sub";
} }
1; 1;

View File

@ -294,12 +294,6 @@ sub _reset {
. build_urlencoded( . build_urlencoded(
mail_token => $req->{id}, mail_token => $req->{id},
skin => $self->p->getSkin($req), skin => $self->p->getSkin($req),
(
$req->datas->{_authChoice}
? ( $self->conf->{authChoiceParam} =>
$req->datas->{_authChoice} )
: ()
),
( $req->datas->{_url} ? ( url => $req->datas->{_url} ) : () ), ( $req->datas->{_url} ? ( url => $req->datas->{_url} ) : () ),
); );
@ -476,7 +470,6 @@ sub display {
AUTH_ERROR => $req->error, AUTH_ERROR => $req->error,
AUTH_ERROR_TYPE => $req->error_type, AUTH_ERROR_TYPE => $req->error_type,
AUTH_URL => $req->datas->{_url}, AUTH_URL => $req->datas->{_url},
CHOICE_PARAM => $self->conf->{authChoiceParam},
CHOICE_VALUE => $req->{_authChoice}, CHOICE_VALUE => $req->{_authChoice},
EXPMAILDATE => $req->datas->{expMailDate}, EXPMAILDATE => $req->datas->{expMailDate},
EXPMAILTIME => $req->datas->{expMailTime}, EXPMAILTIME => $req->datas->{expMailTime},

View File

@ -291,12 +291,6 @@ sub _register {
. build_urlencoded( . build_urlencoded(
register_token => $req->{id}, register_token => $req->{id},
skin => $self->p->getSkin($req), skin => $self->p->getSkin($req),
(
$req->datas->{_authChoice}
? ( $self->conf->{authChoiceParam} =>
$req->datas->{_authChoice} )
: ()
),
( $req->datas->{_url} ? ( url => $req->datas->{_url} ) : () ), ( $req->datas->{_url} ? ( url => $req->datas->{_url} ) : () ),
); );
@ -373,11 +367,6 @@ sub _register {
$url .= '/?' $url .= '/?'
. build_urlencoded( . build_urlencoded(
skin => $self->p->getSkin($req), skin => $self->p->getSkin($req),
(
$req->datas->{_authChoice}
? ( $self->conf->{authChoiceParam} => $req->datas->{_authChoice} )
: ()
),
( $req->datas->{_url} ? ( url => $req->datas->{_url} ) : () ), ( $req->datas->{_url} ? ( url => $req->datas->{_url} ) : () ),
); );

View File

@ -57,6 +57,7 @@ SKIP: {
or explain( $res->[1], or explain( $res->[1],
'Set-Cookie => lemonldapidp=0; domain=.sp.com; path=/; expires=-1d' ); 'Set-Cookie => lemonldapidp=0; domain=.sp.com; path=/; expires=-1d' );
( $host, $url, $query ) = expectForm( $res, undef, undef, 'confirm', ); ( $host, $url, $query ) = expectForm( $res, undef, undef, 'confirm', );
my $spPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
# Choose SAML issuer # Choose SAML issuer
$query .= '&idp=http%3A%2F%2Fauth.idp.com%2Fsaml%2Fmetadata'; $query .= '&idp=http%3A%2F%2Fauth.idp.com%2Fsaml%2Fmetadata';
@ -65,10 +66,11 @@ SKIP: {
'/' => IO::String->new($query), '/' => IO::String->new($query),
accept => 'text/html', accept => 'text/html',
length => length($query), length => length($query),
cookie => 'lemonldapidp=0', cookie => "lemonldapidp=0;$spPdata",
), ),
'Post SAML choice' 'Post SAML choice'
); );
$spPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
ok( expectCookie( $res, 'lemonldapidp' ), 'IDP cookie defined' ) ok( expectCookie( $res, 'lemonldapidp' ), 'IDP cookie defined' )
or explain( or explain(
$res->[1], $res->[1],
@ -116,7 +118,7 @@ SKIP: {
$url, IO::String->new($query), $url, IO::String->new($query),
accept => 'text/html', accept => 'text/html',
length => length($query), length => length($query),
cookie => 'lemonldapidp=http://auth.idp.com/saml/metadata', cookie => "lemonldapidp=http://auth.idp.com/saml/metadata;$spPdata",
), ),
'Post SAML response to SP' 'Post SAML response to SP'
); );

View File

@ -147,6 +147,7 @@ SKIP: {
), ),
'Select "CAS"' 'Select "CAS"'
); );
$proxyPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
ok( expectCookie( $res, 'llngcasserver' ) eq 'idp', ok( expectCookie( $res, 'llngcasserver' ) eq 'idp',
'Get CAS server cookie' ); 'Get CAS server cookie' );