Move assertion resolution in extractFormInfo to pass found user to a userDB module (#584)

This commit is contained in:
Clément Oudot 2013-07-20 08:35:13 +00:00
parent d0d5b560be
commit 5d6239587b

View File

@ -35,6 +35,7 @@ sub authInit {
sub setAuthSessionInfo { sub setAuthSessionInfo {
my $self = shift; my $self = shift;
$self->{sessionInfo}->{_user} = $self->{user};
$self->{sessionInfo}->{authenticationLevel} = $self->{browserIdAuthnLevel}; $self->{sessionInfo}->{authenticationLevel} = $self->{browserIdAuthnLevel};
PE_OK; PE_OK;
@ -46,28 +47,13 @@ sub setAuthSessionInfo {
sub extractFormInfo { sub extractFormInfo {
my $self = shift; my $self = shift;
# Assertion should be in POST browserIdAssertion parameter (ajax call) # Assertion should be browserIdAssertion parameter
if ( $self->{browserIdAssertion} = $self->param('browserIdAssertion') ) { if ( $self->{browserIdAssertion} = $self->param('browserIdAssertion') ) {
$self->lmLog( $self->lmLog(
"BrowserID Assertion found: " . $self->{browserIdAssertion}, "BrowserID Assertion found: " . $self->{browserIdAssertion},
'debug' ); 'debug' );
return PE_OK;
}
# No assertion, return to login page with BrowserID login script
$self->{tpl_browserIdLoadLoginScript} = 1;
return PE_FIRSTACCESS;
}
## @apmethod int authenticate()
# Verify assertion and audience
# @return Lemonldap::NG::Portal constant
sub authenticate {
my $self = shift;
# Return unless BrowserID assertion
return PE_FIRSTACCESS unless ( $self->{browserIdAssertion} );
# Resolve assertion
my $ua = new LWP::UserAgent; my $ua = new LWP::UserAgent;
push @{ $ua->requests_redirectable }, 'POST'; push @{ $ua->requests_redirectable }, 'POST';
@ -93,19 +79,20 @@ sub authenticate {
# Get JSON answser # Get JSON answser
my $browserIdVerificationAnswer = $answer->content; my $browserIdVerificationAnswer = $answer->content;
$self->lmLog( "Received BrowserID answer: $browserIdVerificationAnswer", $self->lmLog(
"Received BrowserID answer: $browserIdVerificationAnswer",
'debug' ); 'debug' );
my $json = new JSON(); my $json = new JSON();
$self->{browserIdAnswer} = $json->decode($browserIdVerificationAnswer); $self->{browserIdAnswer} =
$json->decode($browserIdVerificationAnswer);
if ( $self->{browserIdAnswer}->{status} eq "okay" ) { if ( $self->{browserIdAnswer}->{status} eq "okay" ) {
$self->{_user} = $self->{browserIdAnswer}->{email}; $self->{user} = $self->{browserIdAnswer}->{email};
$self->{sessionInfo}->{user} = $self->{_user};
$self->lmLog( $self->lmLog(
"Found user " "Found user "
. $self->{_user} . $self->{user}
. " in BrowserID verification answer", . " in BrowserID verification answer",
'debug' 'debug'
); );
@ -135,6 +122,19 @@ sub authenticate {
return PE_ERROR; return PE_ERROR;
} }
return PE_OK;
}
# No assertion, return to login page with BrowserID login script
$self->{tpl_browserIdLoadLoginScript} = 1;
return PE_FIRSTACCESS;
}
## @apmethod int authenticate()
# Verify assertion and audience
# @return Lemonldap::NG::Portal constant
sub authenticate {
PE_OK;
} }
## @apmethod int authFinish() ## @apmethod int authFinish()