2013-09-29 09:09:32 +02:00
|
|
|
## @file
|
|
|
|
# UserDB Google module
|
|
|
|
|
|
|
|
## @class
|
|
|
|
# UserDB Google module
|
|
|
|
package Lemonldap::NG::Portal::UserDBGoogle;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Lemonldap::NG::Portal::Simple;
|
2013-10-03 06:18:16 +02:00
|
|
|
use Lemonldap::NG::Common::Regexp;
|
2013-09-29 09:09:32 +02:00
|
|
|
|
2014-02-19 14:56:35 +01:00
|
|
|
our $VERSION = '1.4.0';
|
2013-09-29 09:09:32 +02:00
|
|
|
|
|
|
|
## @apmethod int userDBInit()
|
|
|
|
# Check if authentication module is Google
|
|
|
|
# @return Lemonldap::NG::Portal error code
|
|
|
|
sub userDBInit {
|
|
|
|
my $self = shift;
|
|
|
|
|
2013-10-05 17:59:18 +02:00
|
|
|
unless ( $self->get_module('auth') =~ /^Google/ ) {
|
2013-09-29 09:09:32 +02:00
|
|
|
$self->lmLog(
|
|
|
|
'UserDBGoogle isn\'t useable unless authentication module is set to Google',
|
|
|
|
'error'
|
|
|
|
);
|
|
|
|
return PE_ERROR;
|
|
|
|
}
|
2013-10-05 17:59:18 +02:00
|
|
|
PE_OK;
|
2013-09-29 09:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
## @apmethod int getUser()
|
|
|
|
# Does nothing
|
|
|
|
# @return Lemonldap::NG::Portal error code
|
|
|
|
sub getUser {
|
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @apmethod int setSessionInfo()
|
2013-09-29 20:09:38 +02:00
|
|
|
# Since the job is done by AuthGoogle, here just check that required
|
|
|
|
# attributes are not null
|
2013-09-29 09:09:32 +02:00
|
|
|
# @return Lemonldap::NG::Portal error code
|
|
|
|
sub setSessionInfo {
|
|
|
|
my $self = shift;
|
2014-02-19 14:56:35 +01:00
|
|
|
|
|
|
|
my %vars = ( %{ $self->{exportedVars} }, %{ $self->{googleExportedVars} } );
|
|
|
|
while ( my ( $k, $v ) = each %vars ) {
|
2013-09-29 09:09:32 +02:00
|
|
|
my $attr = $k;
|
2013-09-29 20:09:38 +02:00
|
|
|
next
|
|
|
|
unless ( $attr =~ s/^!//
|
2014-02-19 14:56:35 +01:00
|
|
|
and $v =~ Lemonldap::NG::Common::Regexp::GOOGLEAXATTR() );
|
|
|
|
|
2013-09-29 20:09:38 +02:00
|
|
|
unless ( defined( $self->{sessionInfo}->{$attr} ) ) {
|
2013-09-29 09:09:32 +02:00
|
|
|
$self->lmLog(
|
2013-09-29 18:26:41 +02:00
|
|
|
"Required parameter $attr is not provided by Google server, aborted",
|
|
|
|
'warn'
|
|
|
|
);
|
2013-09-29 09:09:32 +02:00
|
|
|
|
|
|
|
$self->{mustRedirect} = 0;
|
|
|
|
return PE_MISSINGREQATTR;
|
|
|
|
}
|
|
|
|
}
|
2014-02-19 14:56:35 +01:00
|
|
|
|
2013-09-29 09:09:32 +02:00
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @apmethod int setGroups()
|
|
|
|
# Does nothing
|
|
|
|
# @return Lemonldap::NG::Portal error code
|
|
|
|
sub setGroups {
|
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|