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 {
my $self = shift;
$self->{sessionInfo}->{_user} = $self->{user};
$self->{sessionInfo}->{authenticationLevel} = $self->{browserIdAuthnLevel};
PE_OK;
@ -46,28 +47,13 @@ sub setAuthSessionInfo {
sub extractFormInfo {
my $self = shift;
# Assertion should be in POST browserIdAssertion parameter (ajax call)
# Assertion should be browserIdAssertion parameter
if ( $self->{browserIdAssertion} = $self->param('browserIdAssertion') ) {
$self->lmLog(
"BrowserID Assertion found: " . $self->{browserIdAssertion},
'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;
push @{ $ua->requests_redirectable }, 'POST';
@ -93,19 +79,20 @@ sub authenticate {
# Get JSON answser
my $browserIdVerificationAnswer = $answer->content;
$self->lmLog( "Received BrowserID answer: $browserIdVerificationAnswer",
$self->lmLog(
"Received BrowserID answer: $browserIdVerificationAnswer",
'debug' );
my $json = new JSON();
$self->{browserIdAnswer} = $json->decode($browserIdVerificationAnswer);
$self->{browserIdAnswer} =
$json->decode($browserIdVerificationAnswer);
if ( $self->{browserIdAnswer}->{status} eq "okay" ) {
$self->{_user} = $self->{browserIdAnswer}->{email};
$self->{sessionInfo}->{user} = $self->{_user};
$self->{user} = $self->{browserIdAnswer}->{email};
$self->lmLog(
"Found user "
. $self->{_user}
. $self->{user}
. " in BrowserID verification answer",
'debug'
);
@ -135,6 +122,19 @@ sub authenticate {
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()