2010-09-03 15:34:35 +02:00
|
|
|
## @file
|
|
|
|
# UserDB OpenID module
|
|
|
|
|
|
|
|
## @class
|
|
|
|
# UserDB OpenID module
|
|
|
|
package Lemonldap::NG::Portal::UserDBOpenID;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Lemonldap::NG::Portal::Simple;
|
|
|
|
|
2010-11-20 16:05:40 +01:00
|
|
|
our $VERSION = '1.0.0';
|
2010-09-03 15:34:35 +02:00
|
|
|
|
|
|
|
## @apmethod int userDBInit()
|
|
|
|
# Check if authentication module is OpenID
|
|
|
|
# @return Lemonldap::NG::Portal error code
|
|
|
|
sub userDBInit {
|
|
|
|
my $self = shift;
|
2010-10-01 15:04:13 +02:00
|
|
|
|
|
|
|
if ( $self->get_module('auth') eq 'OpenID' ) {
|
2010-09-03 15:34:35 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->lmLog(
|
|
|
|
'UserDBOpenID isn\'t useable unless authentication module is set to OpenID',
|
|
|
|
'error'
|
|
|
|
);
|
|
|
|
return PE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
## @apmethod int getUser()
|
|
|
|
# Does nothing
|
|
|
|
# @return Lemonldap::NG::Portal error code
|
|
|
|
sub getUser {
|
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @apmethod int setSessionInfo()
|
|
|
|
# Check if there are some exportedVars in OpenID response.
|
|
|
|
# See http://openid.net/specs/openid-simple-registration-extension-1_0.html
|
|
|
|
# for more
|
|
|
|
# @return Lemonldap::NG::Portal error code
|
|
|
|
sub setSessionInfo {
|
|
|
|
my $self = shift;
|
|
|
|
if ( ref( $self->{exportedVars} ) eq 'HASH' ) {
|
|
|
|
foreach my $k ( keys %{ $self->{exportedVars} } ) {
|
2010-09-28 18:26:35 +02:00
|
|
|
my $attr = $k;
|
|
|
|
my $required = ( $attr =~ s/^!// );
|
|
|
|
if ( $self->{exportedVars}->{$k} =~
|
2010-09-03 15:34:35 +02:00
|
|
|
/^(?:(?:(?:full|nick)nam|languag|postcod|timezon)e|country|gender|email|dob)$/
|
2010-09-28 18:26:35 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
$self->{sessionInfo}->{$attr} =
|
|
|
|
$self->param("openid.sreg.$self->{exportedVars}->{$k}");
|
|
|
|
}
|
|
|
|
else {
|
2010-10-01 15:21:25 +02:00
|
|
|
$self->lmLog(
|
|
|
|
'Ignoring attribute '
|
|
|
|
. $self->{exportedVars}->{$k}
|
|
|
|
. ' which is not a valid OpenID SREG attribute',
|
|
|
|
'warn'
|
2010-09-28 18:26:35 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:24:56 +02:00
|
|
|
if ( $required and not defined( $self->{sessionInfo}->{$attr} ) ) {
|
2010-09-28 18:26:35 +02:00
|
|
|
$self->lmLog(
|
|
|
|
"Required parameter $attr is not provided by OpenID server, aborted",
|
|
|
|
'warn'
|
2010-09-29 08:42:48 +02:00
|
|
|
);
|
2010-09-24 16:21:19 +02:00
|
|
|
|
2010-10-03 20:32:53 +02:00
|
|
|
$self->{mustRedirect} = 0;
|
2010-09-29 09:24:56 +02:00
|
|
|
return PE_MISSINGREQATTR;
|
2010-09-29 08:42:48 +02:00
|
|
|
}
|
2010-09-03 15:34:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->abort('Only hash reference are supported now in exportedVars');
|
|
|
|
}
|
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @apmethod int setGroups()
|
|
|
|
# Does nothing
|
|
|
|
# @return Lemonldap::NG::Portal error code
|
|
|
|
sub setGroups {
|
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|