2019-02-23 09:35:43 +01:00
|
|
|
package Lemonldap::NG::Portal::Plugins::CheckUser;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Mouse;
|
|
|
|
use Lemonldap::NG::Portal::Main::Constants qw(
|
2019-03-07 18:22:16 +01:00
|
|
|
PE_BADCREDENTIALS
|
|
|
|
PE_TOKENEXPIRED
|
|
|
|
PE_NOTOKEN
|
|
|
|
PE_MALFORMEDUSER
|
2019-02-23 09:35:43 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
our $VERSION = '2.0.3';
|
|
|
|
|
2019-04-05 20:03:25 +02:00
|
|
|
extends 'Lemonldap::NG::Portal::Main::Plugin',
|
|
|
|
'Lemonldap::NG::Portal::Lib::_tokenRule';
|
2019-02-23 09:35:43 +01:00
|
|
|
|
|
|
|
# INITIALIZATION
|
|
|
|
|
|
|
|
has ott => (
|
|
|
|
is => 'rw',
|
|
|
|
lazy => 1,
|
|
|
|
default => sub {
|
2019-03-07 18:22:16 +01:00
|
|
|
my $ott =
|
|
|
|
$_[0]->{p}->loadModule('Lemonldap::NG::Portal::Lib::OneTimeToken');
|
2019-02-23 09:35:43 +01:00
|
|
|
$ott->timeout( $_[0]->{conf}->{formTimeout} );
|
|
|
|
return $ott;
|
|
|
|
}
|
|
|
|
);
|
2019-03-09 23:29:10 +01:00
|
|
|
has idRule => ( is => 'rw', default => sub { 1 } );
|
2019-02-23 09:35:43 +01:00
|
|
|
|
2019-02-23 23:02:42 +01:00
|
|
|
sub hAttr {
|
2019-02-24 22:10:45 +01:00
|
|
|
$_[0]->{conf}->{checkUserHiddenAttributes} . ' '
|
2019-03-07 18:22:16 +01:00
|
|
|
. $_[0]->{conf}->{hiddenAttributes};
|
2019-02-23 23:02:42 +01:00
|
|
|
}
|
|
|
|
|
2019-02-23 09:35:43 +01:00
|
|
|
sub init {
|
|
|
|
my ($self) = @_;
|
2019-03-09 23:29:10 +01:00
|
|
|
my $hd = $self->p->HANDLER;
|
2019-02-25 10:58:06 +01:00
|
|
|
$self->addAuthRoute( checkuser => 'check', ['POST'] );
|
|
|
|
$self->addAuthRoute( checkuser => 'display', ['GET'] );
|
2019-03-09 23:29:10 +01:00
|
|
|
|
|
|
|
# Parse identity rule
|
|
|
|
$self->logger->debug(
|
|
|
|
"checkUser identities rule -> " . $self->conf->{checkUserIdRule} );
|
|
|
|
my $rule =
|
|
|
|
$hd->buildSub( $hd->substitute( $self->conf->{checkUserIdRule} ) );
|
|
|
|
unless ($rule) {
|
|
|
|
$self->error(
|
|
|
|
"Bad checkUser identities rule -> " . $hd->tsv->{jail}->error );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
$self->{idRule} = $rule;
|
|
|
|
|
2019-02-23 09:35:43 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# RUNNING METHOD
|
|
|
|
|
|
|
|
sub check {
|
2019-02-24 22:10:45 +01:00
|
|
|
my ( $self, $req ) = @_;
|
2019-02-26 18:58:44 +01:00
|
|
|
my ( $attrs, $array_attrs, $array_hdrs ) = ( {}, [], [] );
|
|
|
|
my $msg = my $auth = '';
|
2019-02-23 09:35:43 +01:00
|
|
|
|
2019-02-25 10:58:06 +01:00
|
|
|
# Check token
|
2019-04-05 20:03:25 +02:00
|
|
|
if ( $self->ottRule->( $req, {} ) ) {
|
2019-02-25 10:58:06 +01:00
|
|
|
my $token = $req->param('token');
|
|
|
|
unless ($token) {
|
2019-03-07 23:39:37 +01:00
|
|
|
$self->userLogger->warn('checkUser try without token');
|
2019-02-25 20:11:32 +01:00
|
|
|
$msg = PE_NOTOKEN;
|
2019-03-07 17:15:03 +01:00
|
|
|
$token = $self->ott->createToken( $req->userData );
|
2019-02-25 10:58:06 +01:00
|
|
|
}
|
|
|
|
unless ( $self->ott->getToken($token) ) {
|
2019-03-07 23:39:37 +01:00
|
|
|
$self->userLogger->warn('checkUser try with expired/bad token');
|
2019-02-25 20:11:32 +01:00
|
|
|
$msg = PE_TOKENEXPIRED;
|
2019-03-07 17:15:03 +01:00
|
|
|
$token = $self->ott->createToken( $req->userData );
|
2019-02-25 10:58:06 +01:00
|
|
|
}
|
2019-03-07 18:15:48 +01:00
|
|
|
my $params = {
|
|
|
|
PORTAL => $self->conf->{portal},
|
|
|
|
MAIN_LOGO => $self->conf->{portalMainLogo},
|
|
|
|
LANGS => $self->conf->{showLanguages},
|
|
|
|
MSG => "PE$msg",
|
|
|
|
ALERTE => 'alert-warning',
|
2019-03-10 22:01:55 +01:00
|
|
|
LOGIN => '',
|
2019-03-07 18:15:48 +01:00
|
|
|
TOKEN => $token,
|
|
|
|
};
|
2019-03-07 18:22:16 +01:00
|
|
|
return $self->p->sendJSONresponse( $req, $params )
|
|
|
|
if ( $req->wantJSON );
|
|
|
|
return $self->p->sendHtml( $req, 'checkuser', params => $params, )
|
|
|
|
if $msg;
|
2019-02-25 10:58:06 +01:00
|
|
|
}
|
|
|
|
|
2019-02-24 22:30:46 +01:00
|
|
|
## Check user session datas
|
2019-02-23 09:35:43 +01:00
|
|
|
# Use submitted attribute if exists
|
2019-03-07 15:19:04 +01:00
|
|
|
my $url = $req->param('url') || '';
|
|
|
|
my $user = $req->param('user') || '';
|
|
|
|
|
2019-03-07 18:22:16 +01:00
|
|
|
if ( $user and $user !~ /$self->{conf}->{userControl}/o ) {
|
2019-03-07 18:15:48 +01:00
|
|
|
$user = '';
|
|
|
|
$attrs = {};
|
2019-03-07 18:22:16 +01:00
|
|
|
return $self->p->sendError( $req, 'Malformed user', 400 )
|
|
|
|
if ( $req->wantJSON );
|
2019-03-07 18:15:48 +01:00
|
|
|
return $self->p->sendHtml(
|
|
|
|
$req,
|
|
|
|
'checkuser',
|
|
|
|
params => {
|
|
|
|
PORTAL => $self->conf->{portal},
|
|
|
|
MAIN_LOGO => $self->conf->{portalMainLogo},
|
|
|
|
LANGS => $self->conf->{showLanguages},
|
|
|
|
MSG => 'PE' . PE_MALFORMEDUSER,
|
|
|
|
ALERTE => 'alert-warning',
|
2019-03-09 23:29:10 +01:00
|
|
|
LOGIN => '',
|
2019-03-07 18:15:48 +01:00
|
|
|
TOKEN => (
|
2019-04-05 20:03:25 +02:00
|
|
|
$self->ottRule->( $req, {} )
|
2019-03-07 18:15:48 +01:00
|
|
|
? $self->ott->createToken( $req->userData )
|
|
|
|
: ''
|
|
|
|
)
|
|
|
|
}
|
|
|
|
);
|
2019-03-06 23:08:22 +01:00
|
|
|
}
|
|
|
|
|
2019-03-07 15:19:04 +01:00
|
|
|
if ( $user eq $req->{user} or !$user ) {
|
2019-03-06 19:26:32 +01:00
|
|
|
$self->userLogger->notice("Retrieve session from Sessions database");
|
|
|
|
$self->userLogger->warn("Using spoofed SSO groups if exist!!!")
|
2019-03-07 18:22:16 +01:00
|
|
|
if ( $self->conf->{impersonationRule} );
|
2019-03-06 19:26:32 +01:00
|
|
|
$attrs = $req->userData;
|
|
|
|
}
|
|
|
|
else {
|
2019-03-07 23:39:37 +01:00
|
|
|
$self->logger->debug("checkUser requested for $req->{user}");
|
2019-03-07 15:19:04 +01:00
|
|
|
$req->{user} = $user;
|
2019-03-07 10:47:14 +01:00
|
|
|
$self->userLogger->notice(
|
|
|
|
"Retrieve session from userDB and compute Groups & Macros");
|
2019-03-06 19:26:32 +01:00
|
|
|
$attrs = $self->_userDatas($req);
|
|
|
|
}
|
|
|
|
|
2019-02-23 09:35:43 +01:00
|
|
|
if ( $req->error ) {
|
2019-03-06 17:59:09 +01:00
|
|
|
$msg = 'PE' . $req->{error};
|
2019-03-02 11:45:59 +01:00
|
|
|
$array_attrs = [ [], [], [] ];
|
2019-03-06 17:59:09 +01:00
|
|
|
$attrs = {};
|
2019-02-23 09:35:43 +01:00
|
|
|
}
|
2019-02-26 19:30:49 +01:00
|
|
|
else {
|
2019-03-01 12:36:37 +01:00
|
|
|
$msg = 'checkUser';
|
2019-02-23 09:35:43 +01:00
|
|
|
|
2019-02-26 19:30:49 +01:00
|
|
|
# Create an array of hashes for template loop
|
|
|
|
$self->logger->debug("Delete hidden or empty attributes");
|
2019-03-01 12:36:37 +01:00
|
|
|
if ( $self->conf->{checkUserDisplayEmptyValues} ) {
|
|
|
|
foreach my $k ( sort keys %$attrs ) {
|
2019-02-23 20:39:53 +01:00
|
|
|
|
2019-03-01 12:36:37 +01:00
|
|
|
# Ignore hidden attributes
|
2019-02-26 19:30:49 +01:00
|
|
|
push @$array_attrs, { key => $k, value => $attrs->{$k} }
|
2019-03-07 18:22:16 +01:00
|
|
|
unless ( $self->hAttr =~ /\b$k\b/ );
|
2019-02-26 19:30:49 +01:00
|
|
|
}
|
2019-03-01 12:36:37 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
foreach my $k ( sort keys %$attrs ) {
|
|
|
|
|
|
|
|
# Ignore hidden attributes and empty values
|
2019-02-26 19:30:49 +01:00
|
|
|
push @$array_attrs, { key => $k, value => $attrs->{$k} }
|
2019-03-07 18:22:16 +01:00
|
|
|
unless ( $self->hAttr =~ /\b$k\b/ or !$attrs->{$k} );
|
2019-02-26 19:30:49 +01:00
|
|
|
}
|
2019-02-25 20:11:32 +01:00
|
|
|
}
|
2019-03-01 12:36:37 +01:00
|
|
|
|
|
|
|
# ARRAY_REF = [ A_REF GROUPS, A_REF MACROS, A_REF OTHERS ]
|
|
|
|
$array_attrs = $self->_splitAttributes($array_attrs);
|
2019-02-23 20:39:53 +01:00
|
|
|
}
|
|
|
|
|
2019-02-23 09:35:43 +01:00
|
|
|
# Check if user is allowed to access submitted URL and compute headers
|
2019-02-23 20:39:53 +01:00
|
|
|
if ( $url and %$attrs ) {
|
2019-02-23 09:35:43 +01:00
|
|
|
|
2019-04-02 21:39:16 +02:00
|
|
|
# Check url format
|
|
|
|
$url = $self->_urlFormat($url);
|
|
|
|
|
2019-02-23 09:35:43 +01:00
|
|
|
# User is allowed ?
|
2019-02-24 22:30:46 +01:00
|
|
|
$auth = $self->_authorization( $req, $url );
|
2019-02-23 20:39:53 +01:00
|
|
|
$self->logger->debug(
|
|
|
|
"checkUser requested for user: $req->{user} and URL: $url");
|
2019-03-04 20:53:39 +01:00
|
|
|
if ( $auth >= 0 ) {
|
2019-02-23 20:39:53 +01:00
|
|
|
|
2019-03-04 20:53:39 +01:00
|
|
|
$auth = $auth ? "allowed" : "forbidden";
|
|
|
|
$self->userLogger->notice( "checkUser -> $req->{user} is "
|
2019-03-07 18:22:16 +01:00
|
|
|
. uc($auth)
|
|
|
|
. " to access: $url" );
|
2019-03-04 20:53:39 +01:00
|
|
|
|
|
|
|
# Return VirtualHost headers
|
|
|
|
$array_hdrs = $self->_headers( $req, $url );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$auth = 'VHnotFound';
|
|
|
|
$self->userLogger->notice(
|
|
|
|
"checkUser -> URL: $url has no configuration");
|
|
|
|
}
|
2019-02-23 09:35:43 +01:00
|
|
|
}
|
|
|
|
|
2019-03-04 20:53:39 +01:00
|
|
|
my $alert_auth = 'alert-warning';
|
|
|
|
if ( $auth eq 'allowed' ) { $alert_auth = 'alert-success' }
|
|
|
|
elsif ( $auth eq 'forbidden' ) { $alert_auth = 'alert-danger' }
|
|
|
|
|
2019-03-07 18:15:48 +01:00
|
|
|
# TODO:
|
|
|
|
my $params = {
|
|
|
|
PORTAL => $self->conf->{portal},
|
|
|
|
MAIN_LOGO => $self->conf->{portalMainLogo},
|
|
|
|
LANGS => $self->conf->{showLanguages},
|
|
|
|
MSG => $msg,
|
2019-03-07 18:22:16 +01:00
|
|
|
ALERTE => ( $msg eq 'checkUser' ? 'alert-info' : 'alert-warning' ),
|
|
|
|
LOGIN => (
|
2019-03-09 23:29:10 +01:00
|
|
|
$self->p->checkXSSAttack( 'LOGIN', $req->{userData}->{uid} ) ? ""
|
|
|
|
: $req->{userData}->{uid}
|
2019-03-07 18:15:48 +01:00
|
|
|
),
|
|
|
|
URL => (
|
|
|
|
$self->p->checkXSSAttack( 'URL', $url ) ? ""
|
|
|
|
: $url
|
|
|
|
),
|
|
|
|
ALLOWED => $auth,
|
|
|
|
ALERTE_AUTH => $alert_auth,
|
|
|
|
HEADERS => $array_hdrs,
|
|
|
|
ATTRIBUTES => $array_attrs->[2],
|
|
|
|
MACROS => $array_attrs->[1],
|
|
|
|
GROUPS => $array_attrs->[0],
|
|
|
|
TOKEN => (
|
2019-04-05 20:03:25 +02:00
|
|
|
$self->ottRule->( $req, {} )
|
2019-03-07 18:15:48 +01:00
|
|
|
? $self->ott->createToken( $req->userData )
|
|
|
|
: ''
|
|
|
|
)
|
|
|
|
};
|
2019-03-07 18:22:16 +01:00
|
|
|
return $self->p->sendJSONresponse( $req, $params ) if ( $req->wantJSON );
|
|
|
|
|
2019-02-23 09:35:43 +01:00
|
|
|
# Display form
|
2019-03-07 18:22:16 +01:00
|
|
|
return $self->p->sendHtml( $req, 'checkuser', params => $params, );
|
2019-02-25 10:58:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub display {
|
|
|
|
my ( $self, $req ) = @_;
|
2019-03-12 10:00:23 +01:00
|
|
|
my ( $attrs, $array_attrs ) = ( {}, [] );
|
|
|
|
|
|
|
|
$self->userLogger->notice("Retrieve session from Sessions database");
|
|
|
|
$self->userLogger->warn("Using spoofed SSO groups if exist!!!")
|
|
|
|
if ( $self->conf->{impersonationRule} );
|
|
|
|
$attrs = $req->userData;
|
|
|
|
|
|
|
|
# Create an array of hashes for template loop
|
|
|
|
$self->logger->debug("Delete hidden or empty attributes");
|
|
|
|
if ( $self->conf->{checkUserDisplayEmptyValues} ) {
|
|
|
|
foreach my $k ( sort keys %$attrs ) {
|
|
|
|
|
|
|
|
# Ignore hidden attributes
|
|
|
|
push @$array_attrs, { key => $k, value => $attrs->{$k} }
|
|
|
|
unless ( $self->hAttr =~ /\b$k\b/ );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
foreach my $k ( sort keys %$attrs ) {
|
|
|
|
|
|
|
|
# Ignore hidden attributes and empty values
|
|
|
|
push @$array_attrs, { key => $k, value => $attrs->{$k} }
|
|
|
|
unless ( $self->hAttr =~ /\b$k\b/ or !$attrs->{$k} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# ARRAY_REF = [ A_REF GROUPS, A_REF MACROS, A_REF OTHERS ]
|
|
|
|
$array_attrs = $self->_splitAttributes($array_attrs);
|
2019-02-28 21:59:59 +01:00
|
|
|
|
2019-02-25 10:58:06 +01:00
|
|
|
# Display form
|
2019-03-07 18:15:48 +01:00
|
|
|
my $params = {
|
2019-03-12 10:00:23 +01:00
|
|
|
PORTAL => $self->conf->{portal},
|
|
|
|
MAIN_LOGO => $self->conf->{portalMainLogo},
|
|
|
|
LANGS => $self->conf->{showLanguages},
|
|
|
|
MSG => 'checkUser',
|
|
|
|
ALERTE => 'alert-info',
|
|
|
|
LOGIN => $req->{userData}->{uid},
|
|
|
|
ATTRIBUTES => $array_attrs->[2],
|
|
|
|
MACROS => $array_attrs->[1],
|
|
|
|
GROUPS => $array_attrs->[0],
|
|
|
|
TOKEN => (
|
2019-04-05 20:03:25 +02:00
|
|
|
$self->ottRule->( $req, {} )
|
2019-03-07 18:15:48 +01:00
|
|
|
? $self->ott->createToken( $req->userData )
|
|
|
|
: ''
|
|
|
|
)
|
|
|
|
};
|
2019-03-07 18:22:16 +01:00
|
|
|
return $self->sendJSONresponse( $req, $params ) if ( $req->wantJSON );
|
|
|
|
return $self->p->sendHtml( $req, 'checkuser', params => $params, );
|
2019-02-23 09:35:43 +01:00
|
|
|
}
|
|
|
|
|
2019-04-02 21:39:16 +02:00
|
|
|
sub _urlFormat {
|
|
|
|
my ( $self, $url ) = @_;
|
|
|
|
|
2019-04-09 16:56:00 +02:00
|
|
|
$url = 'http://' . $url unless ( $url =~ m#^https?://[^/]*.*#i );
|
|
|
|
my ( $proto, $vhost, $appuri ) = $url =~ m#^(https?://)([^/]*)(.*)#i;
|
2019-04-05 20:03:25 +02:00
|
|
|
my ($port) = $vhost =~ m#^.+(:\d+)$#;
|
2019-04-02 22:07:35 +02:00
|
|
|
$port ||= '';
|
|
|
|
$vhost =~ s/:\d+$//;
|
2019-04-02 21:39:16 +02:00
|
|
|
$vhost .= $self->conf->{domain} unless ( $vhost =~ /\./ );
|
2019-04-09 16:56:00 +02:00
|
|
|
#$appuri ||= '/';
|
|
|
|
return lc ("$proto$vhost$port") . "$appuri";
|
2019-04-02 21:39:16 +02:00
|
|
|
}
|
|
|
|
|
2019-02-24 22:30:46 +01:00
|
|
|
sub _userDatas {
|
2019-02-23 09:35:43 +01:00
|
|
|
my ( $self, $req ) = @_;
|
|
|
|
|
|
|
|
# Search user in database
|
2019-02-25 10:58:06 +01:00
|
|
|
my $steps = [ 'getUser', 'setSessionInfo', 'setMacros', 'setGroups' ];
|
2019-02-25 20:11:32 +01:00
|
|
|
$self->conf->{checkUserDisplayPersistentInfo}
|
2019-03-07 18:22:16 +01:00
|
|
|
? push @$steps, 'setPersistentSessionInfo', 'setLocalGroups'
|
|
|
|
: push @$steps, 'setLocalGroups';
|
2019-02-25 10:58:06 +01:00
|
|
|
$req->steps($steps);
|
2019-02-23 09:35:43 +01:00
|
|
|
if ( my $error = $self->p->process($req) ) {
|
2019-02-26 19:30:49 +01:00
|
|
|
if ( $error == PE_BADCREDENTIALS ) {
|
2019-03-07 18:22:16 +01:00
|
|
|
$self->userLogger->warn(
|
2019-03-07 23:39:37 +01:00
|
|
|
'checkUser requested for an unvalid user ('
|
|
|
|
. $req->{user}
|
|
|
|
. ")" );
|
2019-02-23 09:35:43 +01:00
|
|
|
}
|
2019-02-23 20:39:53 +01:00
|
|
|
$self->logger->debug("Process returned error: $error");
|
2019-02-23 09:35:43 +01:00
|
|
|
return $req->error($error);
|
|
|
|
}
|
2019-03-09 23:29:10 +01:00
|
|
|
|
|
|
|
# Check identities rule
|
|
|
|
unless ( $self->idRule->( $req, $req->sessionInfo ) ) {
|
|
|
|
$self->userLogger->warn(
|
|
|
|
'checkUser requested for an unvalid user (' . $req->{user} . ")" );
|
|
|
|
$req->{sessionInfo} = {};
|
|
|
|
$self->logger->debug('Identity not authorized');
|
|
|
|
return $req->error(PE_BADCREDENTIALS);
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->logger->debug("Return \"$req->{user}\" sessionInfo");
|
2019-02-23 09:35:43 +01:00
|
|
|
return $req->{sessionInfo};
|
|
|
|
}
|
|
|
|
|
2019-02-24 22:30:46 +01:00
|
|
|
sub _authorization {
|
2019-02-23 11:19:40 +01:00
|
|
|
my ( $self, $req, $uri ) = @_;
|
|
|
|
my ( $vhost, $appuri ) = $uri =~ m#^https?://([^/]*)(.*)#;
|
2019-03-04 20:53:39 +01:00
|
|
|
my $exist = 0;
|
|
|
|
|
2019-04-02 21:39:16 +02:00
|
|
|
$vhost =~ s/:\d+$//;
|
2019-03-06 17:59:09 +01:00
|
|
|
foreach my $vh ( keys %{ $self->conf->{locationRules} } ) {
|
2019-03-04 20:53:39 +01:00
|
|
|
if ( $vh eq $vhost ) {
|
|
|
|
$exist = 1;
|
|
|
|
$self->logger->debug("VirtualHost: $vh found in Conf");
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
2019-03-09 23:29:10 +01:00
|
|
|
|
|
|
|
$self->logger->debug("Return \"$req->{user}\" authorization");
|
2019-03-04 20:53:39 +01:00
|
|
|
return $exist
|
2019-03-07 18:22:16 +01:00
|
|
|
? $self->p->HANDLER->grant( $req, $req->{userData}, $appuri,
|
2019-03-04 20:53:39 +01:00
|
|
|
undef, $vhost )
|
2019-03-07 18:22:16 +01:00
|
|
|
: -1;
|
2019-02-23 09:35:43 +01:00
|
|
|
}
|
|
|
|
|
2019-02-23 23:02:42 +01:00
|
|
|
sub _headers {
|
2019-02-24 22:10:45 +01:00
|
|
|
my ( $self, $req, $uri ) = @_;
|
2019-04-05 20:03:25 +02:00
|
|
|
my ($vhost) = $uri =~ m#^https?://([^/]*).*#;
|
2019-04-02 22:07:35 +02:00
|
|
|
|
2019-02-24 22:10:45 +01:00
|
|
|
$vhost =~ s/:\d+$//;
|
|
|
|
$req->{env}->{HTTP_HOST} = $vhost;
|
|
|
|
$self->p->HANDLER->headersInit( $self->{conf} );
|
2019-03-09 23:29:10 +01:00
|
|
|
|
|
|
|
$self->logger->debug("Return \"$req->{user}\" headers");
|
2019-03-07 17:15:03 +01:00
|
|
|
return $self->p->HANDLER->checkHeaders( $req, $req->{userData} );
|
2019-02-23 23:02:42 +01:00
|
|
|
}
|
|
|
|
|
2019-03-01 12:36:37 +01:00
|
|
|
sub _splitAttributes {
|
|
|
|
my ( $self, $attrs ) = @_;
|
|
|
|
my ( $grps, $mcrs, $others ) = ( [], [], [] );
|
|
|
|
my $macros = $self->{conf}->{macros};
|
|
|
|
$self->logger->debug("Dispatching attributes...");
|
|
|
|
while (@$attrs) {
|
|
|
|
my $element = shift @$attrs;
|
2019-03-06 19:26:32 +01:00
|
|
|
$self->logger->debug(
|
|
|
|
'Processing element: ' . Data::Dumper::Dumper($element) );
|
|
|
|
my $ok = 0;
|
2019-03-01 12:36:37 +01:00
|
|
|
if ( $element->{key} eq 'groups' ) {
|
2019-03-02 11:45:59 +01:00
|
|
|
$self->logger->debug('Key "groups" found');
|
2019-03-01 12:36:37 +01:00
|
|
|
my $separator = $self->{conf}->{multiValuesSeparator};
|
|
|
|
my @tmp = split /\Q$separator/, $element->{value};
|
|
|
|
$grps = [ map { { value => $_ } } sort @tmp ];
|
|
|
|
next;
|
|
|
|
}
|
2019-03-06 17:59:09 +01:00
|
|
|
if (%$macros) {
|
|
|
|
foreach my $key ( sort keys %$macros ) {
|
|
|
|
if ( $element->{key} eq $key ) {
|
2019-03-06 19:26:32 +01:00
|
|
|
$self->logger->debug('Macro found');
|
2019-03-06 17:59:09 +01:00
|
|
|
push @$mcrs, $element;
|
|
|
|
$ok = 1;
|
|
|
|
last;
|
|
|
|
}
|
2019-03-01 12:36:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
push @$others, $element unless $ok;
|
|
|
|
}
|
|
|
|
return [ $grps, $mcrs, $others ];
|
|
|
|
}
|
|
|
|
|
2019-02-23 09:35:43 +01:00
|
|
|
1;
|