lemonldap-ng/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDB/WebID.pm

64 lines
1.2 KiB
Perl
Raw Normal View History

2017-01-30 22:00:54 +01:00
package Lemonldap::NG::Portal::UserDB::WebID;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw(
2021-04-01 23:07:58 +02:00
PE_OK
2017-01-30 22:00:54 +01:00
PE_ERROR
PE_MISSINGREQATTR
);
extends 'Lemonldap::NG::Common::Module';
2021-04-01 23:07:58 +02:00
our $VERSION = '2.0.12';
2017-01-30 22:00:54 +01:00
# INITIALIZATION
sub init {
2021-04-01 23:07:58 +02:00
return 1;
2017-01-30 22:00:54 +01:00
}
# RUNNING METHODS
sub getUser {
2021-04-01 23:07:58 +02:00
return PE_OK;
2017-01-30 22:00:54 +01:00
}
2020-12-22 15:17:23 +01:00
sub findUser {
2021-04-01 23:07:58 +02:00
return PE_OK;
2020-12-22 15:17:23 +01:00
}
2017-01-30 22:00:54 +01:00
sub setSessionInfo {
my ( $self, $req ) = @_;
unless ( $req->data->{_webid} ) {
2017-02-15 07:41:50 +01:00
$self->logger->error('No webid object found');
2017-01-30 22:00:54 +01:00
return PE_ERROR;
}
my %vars = (
%{ $self->conf->{exportedVars} },
%{ $self->conf->{webIDExportedVars} }
);
while ( my ( $k, $v ) = each %vars ) {
my $attr = $k;
my $req;
$attr =~ s/^!// and $req = 1;
eval { $req->{sessionInfo}->{$attr} = $req->data->{_webid}->get($v) };
2017-02-15 07:41:50 +01:00
$self->logger->error("Unable to get $v from FOAF document: $@")
2017-01-30 22:00:54 +01:00
if ($@);
if ( $req and not $req->{sessionInfo}->{$attr} ) {
$self->userLogger->warn(
2017-01-30 22:00:54 +01:00
"Required attribute $v is missing (user: $req->{user})");
return PE_MISSINGREQATTR;
}
}
2021-04-01 23:07:58 +02:00
return PE_OK;
2017-01-30 22:00:54 +01:00
}
sub setGroups {
2021-04-01 23:07:58 +02:00
return PE_OK;
2017-01-30 22:00:54 +01:00
}
1;