2017-01-06 11:57:51 +01:00
|
|
|
# Session server plugin for SOAP call
|
|
|
|
#
|
|
|
|
# This plugin adds the following entry points:
|
|
|
|
# * POST /sessions , methods: getCookies getAttributes isAuthorizedURI
|
|
|
|
# * POST /adminSessions, methods: getAttributes setAttributes isAuthorizedURI
|
2017-01-23 23:15:26 +01:00
|
|
|
# newSession deleteSession getCipheredToken
|
2017-01-06 11:57:51 +01:00
|
|
|
# get_key_from_all_sessions
|
|
|
|
# * POST /config , methods: getConfig lastCfg
|
|
|
|
#
|
|
|
|
# There is no conflict with REST server, they can be used together
|
|
|
|
|
|
|
|
package Lemonldap::NG::Portal::Plugins::SOAPServer;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Mouse;
|
2020-10-09 22:26:00 +02:00
|
|
|
use Lemonldap::NG::Portal::Main::Constants qw(
|
|
|
|
PE_OK
|
|
|
|
PE_FORMEMPTY
|
|
|
|
);
|
2017-01-06 11:57:51 +01:00
|
|
|
|
2020-10-09 22:26:00 +02:00
|
|
|
our $VERSION = '2.0.10';
|
2017-01-06 11:57:51 +01:00
|
|
|
|
2020-10-09 22:26:00 +02:00
|
|
|
extends qw(
|
|
|
|
Lemonldap::NG::Portal::Main::Plugin
|
|
|
|
Lemonldap::NG::Common::Conf::AccessLib
|
|
|
|
);
|
2017-01-06 17:18:57 +01:00
|
|
|
|
|
|
|
has server => ( is => 'rw' );
|
|
|
|
|
2017-03-06 13:18:06 +01:00
|
|
|
has configStorage => (
|
|
|
|
is => 'ro',
|
2017-03-27 18:51:18 +02:00
|
|
|
lazy => 1,
|
2017-03-06 13:18:06 +01:00
|
|
|
default => sub {
|
|
|
|
$_[0]->{p}->HANDLER->localConfig->{configStorage};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2017-01-07 19:04:20 +01:00
|
|
|
has exportedAttr => (
|
|
|
|
is => 'rw',
|
2017-03-27 18:51:18 +02:00
|
|
|
lazy => 1,
|
2017-01-07 19:04:20 +01:00
|
|
|
default => sub {
|
|
|
|
my $conf = $_[0]->{conf};
|
|
|
|
if ( $conf->{exportedAttr} and $conf->{exportedAttr} !~ /^\s*\+/ ) {
|
|
|
|
return [ split /\s+/, $conf->{exportedAttr} ];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my @attributes = (
|
|
|
|
'authenticationLevel', 'groups',
|
2017-03-21 21:52:40 +01:00
|
|
|
'ipAddr', '_startTime',
|
2017-01-07 19:04:20 +01:00
|
|
|
'_utime', '_lastSeen',
|
2019-08-26 17:38:08 +02:00
|
|
|
'_session_id', '_session_kind',
|
2017-01-07 19:04:20 +01:00
|
|
|
);
|
|
|
|
if ( my $exportedAttr = $conf->{exportedAttr} ) {
|
|
|
|
$exportedAttr =~ s/^\s*\+\s+//;
|
|
|
|
@attributes = ( @attributes, split( /\s+/, $exportedAttr ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
# convert @attributes into hash to remove duplicates
|
|
|
|
my %attributes = map( { $_ => 1 } @attributes );
|
|
|
|
%attributes =
|
|
|
|
( %attributes, %{ $conf->{exportedVars} }, %{ $conf->{macros} },
|
|
|
|
);
|
|
|
|
|
|
|
|
return [ sort keys %attributes ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-09-26 07:28:23 +02:00
|
|
|
########
|
|
|
|
# WSDL #
|
|
|
|
########
|
|
|
|
|
|
|
|
has wsdl => (
|
|
|
|
is => 'ro',
|
|
|
|
lazy => 1,
|
|
|
|
default => sub {
|
|
|
|
my ($self) = @_;
|
|
|
|
my @cookies = ( $self->conf->{cookieName} );
|
|
|
|
push @cookies, $self->conf->{cookieName} . 'http'
|
|
|
|
if ( $self->conf->{securedCookie} >= 2 );
|
|
|
|
my $cookieList = join "\n",
|
|
|
|
map { "<element name='$_' type='xsd:string'></element>" } @cookies;
|
|
|
|
|
|
|
|
my $attrList = join "\n", map {
|
|
|
|
"<element name='$_' type='xsd:string' nillable='true'></element>"
|
2019-03-26 21:47:14 +01:00
|
|
|
} @{ $self->exportedAttr };
|
2018-09-26 07:28:23 +02:00
|
|
|
my $resp = join( '', <DATA> );
|
|
|
|
close DATA;
|
|
|
|
$resp =~ s/\$cookieList/$cookieList/g;
|
|
|
|
$resp =~ s/\$attrList/$attrList/g;
|
|
|
|
$resp =~ s/\$portal/$self->conf->{portal}/ge;
|
2018-09-26 20:51:53 +02:00
|
|
|
return [
|
|
|
|
200,
|
|
|
|
[
|
|
|
|
'Content-Type' => 'application/wsdl+xml',
|
|
|
|
'Content-Length' => length($resp)
|
|
|
|
],
|
|
|
|
[$resp]
|
|
|
|
];
|
2018-09-26 07:28:23 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2017-01-06 11:57:51 +01:00
|
|
|
# INITIALIZATION
|
|
|
|
|
|
|
|
sub init {
|
|
|
|
my ($self) = @_;
|
2017-01-07 19:04:20 +01:00
|
|
|
eval {
|
|
|
|
require Lemonldap::NG::Common::PSGI::SOAPServer;
|
|
|
|
require Lemonldap::NG::Common::PSGI::SOAPService;
|
|
|
|
};
|
2017-01-06 17:18:57 +01:00
|
|
|
if ($@) {
|
|
|
|
$self->error($@);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
$self->server( Lemonldap::NG::Common::PSGI::SOAPServer->new );
|
2017-01-08 09:42:16 +01:00
|
|
|
if ( $self->conf->{soapSessionServer} ) {
|
2017-09-06 16:30:47 +02:00
|
|
|
$self->addUnauthRoute(
|
|
|
|
sessions => { '*' => 'unauthSessions' },
|
|
|
|
['POST']
|
2020-10-09 22:26:00 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
->addUnauthRoute(
|
2017-01-08 09:42:16 +01:00
|
|
|
adminSessions => 'unauthAdminSessions',
|
|
|
|
['POST']
|
2020-10-09 22:26:00 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
->addAuthRoute(
|
2017-09-06 16:30:47 +02:00
|
|
|
sessions => { '*' => 'badSoapRequest' },
|
|
|
|
['POST']
|
2020-10-09 22:26:00 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
->addAuthRoute(
|
2017-09-06 16:30:47 +02:00
|
|
|
adminSessions => { '*' => 'badSoapRequest' },
|
|
|
|
['POST']
|
2020-10-09 22:26:00 +02:00
|
|
|
);
|
2017-01-08 09:42:16 +01:00
|
|
|
}
|
|
|
|
if ( $self->conf->{soapConfigServer} ) {
|
2020-10-09 22:26:00 +02:00
|
|
|
$self->addUnauthRoute( config => { '*' => 'config' }, ['POST'] )
|
|
|
|
->addAuthRoute( config => { '*' => 'badSoapRequest' }, ['POST'] );
|
2017-01-08 09:42:16 +01:00
|
|
|
}
|
2018-09-25 06:55:17 +02:00
|
|
|
if ( $self->conf->{wsdlServer} ) {
|
2020-10-09 22:26:00 +02:00
|
|
|
$self->addUnauthRoute( 'portal.wsdl' => 'getWsdl', ['GET'] )
|
|
|
|
->addAuthRoute( 'portal.wsdl' => 'getWsdl', ['GET'] );
|
2018-09-25 06:55:17 +02:00
|
|
|
}
|
2020-10-09 22:26:00 +02:00
|
|
|
|
|
|
|
return 1;
|
2017-01-06 11:57:51 +01:00
|
|
|
}
|
|
|
|
|
2017-01-07 19:04:20 +01:00
|
|
|
# SOAP DISPATCHERS
|
2017-01-06 17:18:57 +01:00
|
|
|
sub unauthSessions {
|
|
|
|
my ( $self, $req ) = @_;
|
2017-01-07 19:04:20 +01:00
|
|
|
return $self->dispatch_to( $req,
|
2018-09-26 07:28:23 +02:00
|
|
|
qw(error getCookies getAttributes isAuthorizedURI getMenuApplications)
|
|
|
|
);
|
2017-01-06 17:18:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub unauthAdminSessions {
|
|
|
|
my ( $self, $req ) = @_;
|
2017-01-07 19:04:20 +01:00
|
|
|
return $self->dispatch_to(
|
|
|
|
$req,
|
|
|
|
qw(getCookies getAttributes isAuthorizedURI getMenuApplications
|
2017-01-23 23:04:24 +01:00
|
|
|
newSession setAttributes deleteSession getCipheredToken
|
|
|
|
get_key_from_all_sessions)
|
2017-01-07 19:04:20 +01:00
|
|
|
);
|
2017-01-06 17:18:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub config {
|
|
|
|
my ( $self, $req ) = @_;
|
2017-01-07 19:04:20 +01:00
|
|
|
return $self->dispatch_to( $req, qw(getConfig lastCfg) );
|
2017-01-06 17:18:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub badSoapRequest {
|
|
|
|
my ( $self, $req ) = @_;
|
2017-01-07 19:04:20 +01:00
|
|
|
return $self->p->sendError( $req, 'Bad request', 400 );
|
|
|
|
}
|
|
|
|
|
|
|
|
# Private dispatcher
|
|
|
|
sub dispatch_to {
|
|
|
|
my ( $self, $req, @functions ) = @_;
|
|
|
|
unless ( $req->env->{HTTP_SOAPACTION} ) {
|
|
|
|
return $self->p->sendError( $req, 'SOAP requests only', 400 );
|
|
|
|
}
|
|
|
|
return $self->server->dispatch_to(
|
|
|
|
Lemonldap::NG::Common::PSGI::SOAPService->new(
|
|
|
|
$self, $req, @functions
|
|
|
|
)
|
|
|
|
)->handle($req);
|
|
|
|
}
|
|
|
|
|
|
|
|
# RESPONSE METHODS
|
|
|
|
|
|
|
|
# Called in SOAP context, returns cookies in an array.
|
|
|
|
# This subroutine works only for portals working with user and password
|
|
|
|
|
2018-09-26 07:28:23 +02:00
|
|
|
sub getWsdl {
|
|
|
|
return $_[0]->wsdl;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub error {
|
|
|
|
my ( $self, $no, $lang ) = @_;
|
|
|
|
return "Error $no";
|
|
|
|
}
|
|
|
|
|
2017-01-07 19:04:20 +01:00
|
|
|
=begin WSDL
|
|
|
|
|
|
|
|
_IN user $string User name
|
|
|
|
_IN password $string Password
|
|
|
|
_RETURN $getCookiesResponse Response
|
|
|
|
|
|
|
|
=end WSDL
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
sub getCookies {
|
|
|
|
my ( $self, $req, $user, $password, $sessionid ) = @_;
|
2017-02-15 07:41:50 +01:00
|
|
|
$self->logger->debug("SOAP authentication request for $user");
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
$req->{user} = $user;
|
2018-07-05 22:56:16 +02:00
|
|
|
$req->data->{password} = $password;
|
2017-01-07 19:04:20 +01:00
|
|
|
if ($sessionid) {
|
|
|
|
$req->{id} = $sessionid;
|
|
|
|
$req->{force} = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$req->{error} = PE_OK;
|
|
|
|
|
|
|
|
# User and password are required
|
2018-07-05 22:56:16 +02:00
|
|
|
unless ( $req->{user} && $req->data->{password} ) {
|
2017-01-07 19:04:20 +01:00
|
|
|
$req->{error} = PE_FORMEMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Launch process
|
|
|
|
else {
|
2019-02-07 09:27:56 +01:00
|
|
|
$req->steps( [
|
2017-02-28 07:34:49 +01:00
|
|
|
qw(getUser authenticate setAuthSessionInfo),
|
2018-07-05 22:56:16 +02:00
|
|
|
@{ $self->p->betweenAuthAndData },
|
|
|
|
$self->p->sessionData,
|
|
|
|
@{ $self->p->afterData },
|
2018-09-05 09:19:01 +02:00
|
|
|
$self->p->validSession,
|
|
|
|
@{ $self->p->endAuth },
|
2017-01-07 19:04:20 +01:00
|
|
|
]
|
|
|
|
);
|
2017-01-07 21:37:07 +01:00
|
|
|
$req->{error} = $self->p->process($req);
|
2017-02-15 07:41:50 +01:00
|
|
|
$self->logger->debug(
|
|
|
|
"SOAP authentication result for $user: code $req->{error}");
|
2017-01-07 19:04:20 +01:00
|
|
|
$self->p->updateSession($req);
|
|
|
|
}
|
|
|
|
my @tmp = ();
|
|
|
|
push @tmp, SOAP::Data->name( errorCode => $req->{error} );
|
|
|
|
my @cookies = ();
|
2017-02-28 07:34:49 +01:00
|
|
|
unless ( $req->{error} ) {
|
2017-01-07 19:04:20 +01:00
|
|
|
for ( my $i = 0 ; $i < @{ $req->respHeaders } ; $i += 2 ) {
|
|
|
|
if ( $req->respHeaders->[$i] eq 'Set-Cookie' ) {
|
|
|
|
my ( $k, $v ) =
|
|
|
|
( $req->respHeaders->[ $i + 1 ] =~ /^(\w+)\s*=\s*([^;]*)/ );
|
|
|
|
push @cookies, SOAP::Data->name( $k, $v )->type("string");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
push @tmp, SOAP::Data->name( cookies => \SOAP::Data->value(@cookies) );
|
|
|
|
my $res = SOAP::Data->name( session => \SOAP::Data->value(@tmp) );
|
2017-01-07 21:37:07 +01:00
|
|
|
|
|
|
|
#TODO: updateStatus
|
|
|
|
#$self->p->updateStatus($req);
|
2017-01-07 19:04:20 +01:00
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Return attributes of the session identified by $id.
|
|
|
|
# @param $id Cookie value
|
|
|
|
|
|
|
|
=begin WSDL
|
|
|
|
|
|
|
|
_IN id $string Cookie value
|
|
|
|
_RETURN $getAttributesResponse Response
|
|
|
|
|
|
|
|
=end WSDL
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
sub getAttributes {
|
|
|
|
my ( $self, $req, $id ) = @_;
|
|
|
|
die 'id is required' unless ($id);
|
|
|
|
|
2019-05-11 15:41:14 +02:00
|
|
|
my $session = $self->p->getApacheSession( $id, kind => '' );
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
my @tmp = ();
|
|
|
|
unless ($session) {
|
2017-02-19 12:51:58 +01:00
|
|
|
$self->userLogger->notice(
|
|
|
|
"SOAP attributes request: session $id not found");
|
2017-01-07 19:04:20 +01:00
|
|
|
push @tmp, SOAP::Data->name( error => 1 )->type('int');
|
|
|
|
}
|
|
|
|
else {
|
2017-01-21 14:22:55 +01:00
|
|
|
my $wtt = $session->data->{ $self->conf->{whatToTrace} };
|
2017-02-15 15:16:59 +01:00
|
|
|
$self->userLogger->info(
|
2017-01-21 14:22:55 +01:00
|
|
|
"SOAP attributes request for " . ( $wtt ? $wtt : $id ) );
|
2017-01-07 19:04:20 +01:00
|
|
|
push @tmp, SOAP::Data->name( error => 0 )->type('int');
|
|
|
|
push @tmp,
|
2018-06-05 20:52:55 +02:00
|
|
|
SOAP::Data->name(
|
|
|
|
attributes => _buildSoapHash(
|
|
|
|
$session->data,
|
2019-02-07 09:27:56 +01:00
|
|
|
( (
|
2018-06-05 23:13:18 +02:00
|
|
|
$session->{_session_kind}
|
|
|
|
and $session->{_session_kind} eq 'SSO'
|
|
|
|
)
|
2018-06-05 20:52:55 +02:00
|
|
|
? ( @{ $self->exportedAttr } )
|
|
|
|
: ()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2017-01-07 19:04:20 +01:00
|
|
|
}
|
|
|
|
my $res = SOAP::Data->name( session => \SOAP::Data->value(@tmp) );
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:56:16 +02:00
|
|
|
# Update data in the session referenced by $id
|
2017-01-07 19:04:20 +01:00
|
|
|
# @param $id Id of the session
|
2018-07-05 22:56:16 +02:00
|
|
|
# @param $args data to store
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
=begin WSDL
|
|
|
|
|
|
|
|
_IN id $string Cookie value
|
|
|
|
_RETURN $setAttributesResponse Response
|
|
|
|
|
|
|
|
=end WSDL
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
sub setAttributes {
|
|
|
|
my ( $self, $req, $id, $args ) = @_;
|
|
|
|
die 'id is required' unless ($id);
|
|
|
|
|
2017-02-20 22:00:05 +01:00
|
|
|
my $infos = {};
|
|
|
|
%$infos = %$args;
|
|
|
|
|
2017-03-03 18:25:03 +01:00
|
|
|
my $session = $self->p->getApacheSession( $id, info => $infos );
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
unless ($session) {
|
2017-02-15 07:41:50 +01:00
|
|
|
$self->logger->warn("Session $id does not exists ($@)");
|
2017-01-07 19:04:20 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-15 07:41:50 +01:00
|
|
|
$self->logger->debug("SOAP request to update session $id");
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Return Lemonldap::NG configuration. Warning, this is not a well formed
|
|
|
|
# SOAP::Data object so it can be difficult to read by other languages than
|
|
|
|
# Perl. It's not really a problem since this function is written to be read by
|
|
|
|
# Lemonldap::NG components and is not designed to be shared.
|
|
|
|
|
|
|
|
sub getConfig {
|
|
|
|
my ( $self, $req, $id ) = @_;
|
2017-01-11 22:10:13 +01:00
|
|
|
my $conf = $self->confAcc->getConf( { raw => 1, cfgNum => $id } )
|
2017-01-07 19:04:20 +01:00
|
|
|
or die("No configuration available");
|
|
|
|
return $conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
# SOAP method that return the last configuration number.
|
|
|
|
# Call Lemonldap::NG::Common::Conf::lastCfg().
|
|
|
|
|
|
|
|
sub lastCfg {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->confAcc->lastCfg;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Store a new session.
|
|
|
|
|
|
|
|
sub newSession {
|
|
|
|
my ( $self, $req, $args ) = @_;
|
|
|
|
|
2017-01-21 14:22:55 +01:00
|
|
|
$args ||= {};
|
2017-01-07 19:04:20 +01:00
|
|
|
my $infos = {};
|
|
|
|
%$infos = %$args;
|
|
|
|
$infos->{_utime} = time();
|
|
|
|
|
2017-03-03 18:25:03 +01:00
|
|
|
my $session = $self->p->getApacheSession( undef, info => $infos );
|
2017-02-20 22:00:05 +01:00
|
|
|
|
|
|
|
unless ($session) {
|
|
|
|
$self->logger->error("Unable to create session");
|
|
|
|
return 0;
|
|
|
|
}
|
2017-01-07 19:04:20 +01:00
|
|
|
|
2017-02-15 07:41:50 +01:00
|
|
|
$self->logger->debug(
|
|
|
|
"SOAP request create a new session (" . $session->id . ")" );
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
return SOAP::Data->name( attributes => _buildSoapHash( $session->data ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
# Deletes an existing session
|
|
|
|
|
|
|
|
sub deleteSession {
|
|
|
|
my ( $self, $req, $id ) = @_;
|
|
|
|
die('id parameter is required') unless ($id);
|
|
|
|
|
2019-06-14 17:23:26 +02:00
|
|
|
my $session = $self->p->getApacheSession( $id, kind => '' );
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
return 0 unless ($session);
|
|
|
|
|
2017-02-15 07:41:50 +01:00
|
|
|
$self->logger->debug("SOAP request to delete session $id");
|
2017-01-07 19:04:20 +01:00
|
|
|
|
2017-01-23 06:49:32 +01:00
|
|
|
return $self->p->_deleteSession( $req, $session );
|
2017-01-07 19:04:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Returns key from all sessions
|
|
|
|
|
2017-01-23 23:04:24 +01:00
|
|
|
sub getCipheredToken {
|
|
|
|
my ( $self, $req ) = @_;
|
|
|
|
require Lemonldap::NG::Portal::Lib::OneTimeToken;
|
|
|
|
return $self->conf->{cipher}->encrypt(
|
|
|
|
Lemonldap::NG::Portal::Lib::OneTimeToken->new(
|
|
|
|
{ p => $self->p, conf => $self->conf, timeout => 5 }
|
|
|
|
)->createToken()
|
|
|
|
);
|
|
|
|
}
|
2017-01-07 19:04:20 +01:00
|
|
|
|
2017-01-23 23:04:24 +01:00
|
|
|
sub get_key_from_all_sessions {
|
|
|
|
my $self = shift;
|
|
|
|
my $req = shift;
|
|
|
|
my $token = shift;
|
|
|
|
|
|
|
|
# Verify that token is valid (must be unciphered by client)
|
|
|
|
require Lemonldap::NG::Portal::Lib::OneTimeToken;
|
|
|
|
unless (
|
|
|
|
Lemonldap::NG::Portal::Lib::OneTimeToken->new(
|
|
|
|
{ p => $self->p, conf => $self->conf }
|
|
|
|
)->getToken($token)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
die SOAP::Fault->faultcode('Server.Custom')->faultstring('Bad token');
|
|
|
|
}
|
2017-01-07 19:04:20 +01:00
|
|
|
my $moduleOptions = $self->conf->{globalStorageOptions} || {};
|
|
|
|
$moduleOptions->{backend} = $self->conf->{globalStorage};
|
2017-01-23 23:04:24 +01:00
|
|
|
require Lemonldap::NG::Common::Apache::Session;
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
no strict 'refs';
|
2017-01-23 23:04:24 +01:00
|
|
|
return Lemonldap::NG::Common::Apache::Session->get_key_from_all_sessions(
|
|
|
|
$moduleOptions, @_ );
|
2017-01-07 19:04:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Check user's authorization for uri.
|
|
|
|
# @param $id Id of the session
|
|
|
|
# @param $uri URL string
|
|
|
|
|
|
|
|
=begin WSDL
|
|
|
|
|
|
|
|
_IN id $string Cookie value
|
|
|
|
_IN uri $string URI to test
|
|
|
|
_RETURN $isAuthorizedURIResponse Response
|
|
|
|
|
|
|
|
=end WSDL
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
sub isAuthorizedURI {
|
|
|
|
my ( $self, $req, $id, $url ) = @_;
|
|
|
|
die 'id is required' unless ($id);
|
|
|
|
die 'uri is required' unless ($url);
|
|
|
|
die 'Bad uri' unless ( $url =~ m#^https?://([^/]+)(/.*)?$# );
|
|
|
|
my ( $host, $uri ) = ( $1, $2 );
|
|
|
|
|
|
|
|
# Get user session.
|
2017-01-24 06:10:57 +01:00
|
|
|
my $session = $self->p->getApacheSession($id);
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
unless ($session) {
|
2017-02-15 07:41:50 +01:00
|
|
|
$self->logger->warn("Session $id does not exists");
|
2017-01-07 19:04:20 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-03 13:17:15 +01:00
|
|
|
$req->{sessionInfo} = $session->data;
|
2017-03-28 23:07:49 +02:00
|
|
|
my $r =
|
|
|
|
$self->p->HANDLER->grant( $req, $req->{sessionInfo}, $uri, undef, $host );
|
2017-01-07 19:04:20 +01:00
|
|
|
|
|
|
|
return $r;
|
|
|
|
}
|
|
|
|
|
|
|
|
# @param $id Id of the session
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Private subroutines #
|
|
|
|
#######################
|
|
|
|
|
|
|
|
##@fn private SOAP::Data _buildSoapHash()
|
|
|
|
# Serialize a hashref into SOAP::Data. Types are fixed to "string".
|
2018-07-05 22:56:16 +02:00
|
|
|
# @return SOAP::Data serialized data
|
2017-01-07 19:04:20 +01:00
|
|
|
sub _buildSoapHash {
|
|
|
|
my ( $h, @keys ) = @_;
|
|
|
|
my @tmp = ();
|
|
|
|
@keys = keys %$h unless (@keys);
|
|
|
|
foreach (@keys) {
|
|
|
|
if ( ref( $h->{$_} ) eq 'ARRAY' ) {
|
|
|
|
push @tmp, SOAP::Data->name( $_, @{ $h->{$_} } );
|
|
|
|
}
|
|
|
|
elsif ( ref( $h->{$_} ) ) {
|
|
|
|
push @tmp, SOAP::Data->name( $_ => _buildSoapHash( $h->{$_} ) );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
push @tmp, SOAP::Data->name( $_, $h->{$_} )->type('string')
|
|
|
|
if ( defined( $h->{$_} ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return \SOAP::Data->value(@tmp);
|
2017-01-06 17:18:57 +01:00
|
|
|
}
|
|
|
|
|
2017-01-06 11:57:51 +01:00
|
|
|
1;
|
2018-09-25 06:55:17 +02:00
|
|
|
|
|
|
|
__DATA__
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
|
|
<wsdl:definitions
|
2018-09-26 07:32:28 +02:00
|
|
|
targetNamespace="urn:Lemonldap/NG/Common/PSGI/SOAPService"
|
|
|
|
xmlns:impl="urn:Lemonldap/NG/Common/PSGI/SOAPService"
|
2018-09-25 06:55:17 +02:00
|
|
|
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
|
|
|
|
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
|
|
|
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
|
|
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
2018-09-26 07:32:28 +02:00
|
|
|
xmlns:tns1="urn:Lemonldap/NG/Common/PSGI/SOAPService">
|
2018-09-25 06:55:17 +02:00
|
|
|
|
|
|
|
<!-- types definitions -->
|
|
|
|
|
|
|
|
<wsdl:types>
|
2018-09-26 07:32:28 +02:00
|
|
|
<schema targetNamespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" xmlns="http://www.w3.org/2001/XMLSchema">
|
2018-09-25 06:55:17 +02:00
|
|
|
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
|
|
|
|
|
|
|
|
<complexType name="CookiesSequence">
|
|
|
|
<sequence>
|
|
|
|
$cookieList
|
|
|
|
</sequence>
|
|
|
|
</complexType>
|
|
|
|
<complexType name="AttributesSequence">
|
|
|
|
<sequence>
|
|
|
|
$attrList
|
|
|
|
</sequence>
|
|
|
|
</complexType>
|
|
|
|
<complexType name="GetCookieResponse">
|
|
|
|
<sequence>
|
|
|
|
<element name="errorCode" type="xsd:int"></element>
|
|
|
|
<element name="cookies" minOccurs="0" type="tns1:CookiesSequence"></element>
|
|
|
|
</sequence>
|
|
|
|
</complexType>
|
|
|
|
<complexType name="GetAttributesResponse">
|
|
|
|
<sequence>
|
|
|
|
<element name="error" type="xsd:int"></element>
|
|
|
|
<element name="attributes" type="tns1:AttributesSequence"></element>
|
|
|
|
</sequence>
|
|
|
|
</complexType>
|
|
|
|
|
|
|
|
</schema>
|
|
|
|
</wsdl:types>
|
|
|
|
|
2018-09-26 07:28:23 +02:00
|
|
|
<!-- sessions service -->
|
2018-09-25 06:55:17 +02:00
|
|
|
|
|
|
|
<wsdl:message name="errorRequest">
|
|
|
|
<wsdl:part name="code" type="xsd:int" />
|
|
|
|
<wsdl:part name="lang" type="xsd:string" />
|
|
|
|
</wsdl:message>
|
|
|
|
<wsdl:message name="errorResponse">
|
|
|
|
<wsdl:part name="result" type="xsd:string" />
|
|
|
|
</wsdl:message>
|
|
|
|
|
|
|
|
<wsdl:message name="getCookiesRequest">
|
|
|
|
<wsdl:part name="user" type="xsd:string" />
|
|
|
|
<wsdl:part name="password" type="xsd:string" />
|
|
|
|
</wsdl:message>
|
|
|
|
<wsdl:message name="getCookiesResponse">
|
|
|
|
<wsdl:part name="session" type="tns1:GetCookieResponse" />
|
|
|
|
</wsdl:message>
|
|
|
|
|
|
|
|
<wsdl:message name="getAttributesRequest">
|
|
|
|
<wsdl:part name="id" type="xsd:string" />
|
|
|
|
</wsdl:message>
|
|
|
|
<wsdl:message name="getAttributesResponse">
|
|
|
|
<wsdl:part name="session" type="tns1:GetAttributesResponse" />
|
|
|
|
</wsdl:message>
|
|
|
|
|
|
|
|
<wsdl:message name="isAuthorizedURIRequest">
|
|
|
|
<wsdl:part name="id" type="xsd:string" />
|
|
|
|
<wsdl:part name="uri" type="xsd:string" />
|
|
|
|
</wsdl:message>
|
|
|
|
<wsdl:message name="isAuthorizedURIResponse">
|
|
|
|
<wsdl:part name="result" type="xsd:int" />
|
|
|
|
</wsdl:message>
|
|
|
|
|
|
|
|
<wsdl:message name="getMenuApplicationsRequest">
|
|
|
|
<wsdl:part name="id" type="xsd:string" />
|
|
|
|
</wsdl:message>
|
|
|
|
<wsdl:message name="getMenuApplicationsResponse">
|
|
|
|
<wsdl:part name="result" type="xsd:anyType" />
|
|
|
|
</wsdl:message>
|
|
|
|
|
|
|
|
<wsdl:portType name="sessionsPortType">
|
2018-09-26 07:28:23 +02:00
|
|
|
<wsdl:operation name="error" parameterOrder="code lang">
|
|
|
|
<wsdl:input message="impl:errorRequest" name="errorRequest" />
|
|
|
|
<wsdl:output message="impl:errorResponse" name="errorResponse" />
|
|
|
|
</wsdl:operation>
|
|
|
|
<wsdl:operation name="getCookies" parameterOrder="user password">
|
|
|
|
<wsdl:input message="impl:getCookiesRequest" name="getCookiesRequest" />
|
|
|
|
<wsdl:output message="impl:getCookiesResponse" name="getCookiesResponse" />
|
|
|
|
</wsdl:operation>
|
2018-09-25 06:55:17 +02:00
|
|
|
<wsdl:operation name="getAttributes" parameterOrder="id">
|
|
|
|
<wsdl:input message="impl:getAttributesRequest" name="getAttributesRequest" />
|
|
|
|
<wsdl:output message="impl:getAttributesResponse" name="getAttributesResponse" />
|
|
|
|
</wsdl:operation>
|
|
|
|
<wsdl:operation name="isAuthorizedURI" parameterOrder="id uri">
|
|
|
|
<wsdl:input message="impl:isAuthorizedURIRequest" name="isAuthorizedURIRequest" />
|
|
|
|
<wsdl:output message="impl:isAuthorizedURIResponse" name="isAuthorizedURIResponse" />
|
|
|
|
</wsdl:operation>
|
|
|
|
<wsdl:operation name="getMenuApplications" parameterOrder="id">
|
|
|
|
<wsdl:input message="impl:getMenuApplicationsRequest" name="getMenuApplicationsRequest" />
|
|
|
|
<wsdl:output message="impl:getMenuApplicationsResponse" name="getMenuApplicationsResponse" />
|
|
|
|
</wsdl:operation>
|
|
|
|
</wsdl:portType>
|
|
|
|
|
|
|
|
<wsdl:binding name="sessionsBinding" type="impl:sessionsPortType">
|
|
|
|
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
|
2018-09-26 07:28:23 +02:00
|
|
|
<wsdl:operation name="error">
|
|
|
|
<wsdlsoap:operation soapAction="" />
|
|
|
|
<wsdl:input name="errorRequest">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-26 07:28:23 +02:00
|
|
|
</wsdl:input>
|
|
|
|
<wsdl:output name="errorResponse">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-26 07:28:23 +02:00
|
|
|
</wsdl:output>
|
|
|
|
</wsdl:operation>
|
|
|
|
<wsdl:operation name="getCookies">
|
|
|
|
<wsdlsoap:operation soapAction="" />
|
|
|
|
<wsdl:input name="getCookiesRequest">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-26 07:28:23 +02:00
|
|
|
</wsdl:input>
|
|
|
|
<wsdl:output name="getCookiesResponse">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-26 07:28:23 +02:00
|
|
|
</wsdl:output>
|
|
|
|
</wsdl:operation>
|
2018-09-25 06:55:17 +02:00
|
|
|
<wsdl:operation name="getAttributes">
|
|
|
|
<wsdlsoap:operation soapAction="" />
|
|
|
|
<wsdl:input name="getAttributesRequest">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-25 06:55:17 +02:00
|
|
|
</wsdl:input>
|
|
|
|
<wsdl:output name="getAttributesResponse">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-25 06:55:17 +02:00
|
|
|
</wsdl:output>
|
|
|
|
</wsdl:operation>
|
|
|
|
<wsdl:operation name="isAuthorizedURI">
|
|
|
|
<wsdlsoap:operation soapAction="" />
|
|
|
|
<wsdl:input name="isAuthorizedURIRequest">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-25 06:55:17 +02:00
|
|
|
</wsdl:input>
|
|
|
|
<wsdl:output name="isAuthorizedURIResponse">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-25 06:55:17 +02:00
|
|
|
</wsdl:output>
|
|
|
|
</wsdl:operation>
|
|
|
|
<wsdl:operation name="getMenuApplications">
|
|
|
|
<wsdlsoap:operation soapAction="" />
|
|
|
|
<wsdl:input name="getMenuApplicationsRequest">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-25 06:55:17 +02:00
|
|
|
</wsdl:input>
|
|
|
|
<wsdl:output name="getMenuApplicationsResponse">
|
2018-09-26 07:32:28 +02:00
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
2018-09-25 06:55:17 +02:00
|
|
|
</wsdl:output>
|
|
|
|
</wsdl:operation>
|
|
|
|
|
|
|
|
</wsdl:binding>
|
|
|
|
|
|
|
|
<wsdl:service name="sessionsService">
|
|
|
|
<wsdl:port binding="impl:sessionsBinding" name="sessionsPort">
|
|
|
|
<wsdlsoap:address location="$portal/sessions" />
|
|
|
|
</wsdl:port>
|
|
|
|
</wsdl:service>
|
|
|
|
|
2018-09-26 07:28:23 +02:00
|
|
|
<!-- end sessions service -->
|
|
|
|
|
2018-09-26 20:51:53 +02:00
|
|
|
<!-- notification service -->
|
|
|
|
|
|
|
|
<wsdl:message name="newNotificationRequest">
|
|
|
|
<wsdl:part name="notification" type="xsd:string" />
|
|
|
|
</wsdl:message>
|
|
|
|
<wsdl:message name="newNotificationResponse">
|
|
|
|
<wsdl:part name="result" type="xsd:int" />
|
|
|
|
</wsdl:message>
|
|
|
|
<wsdl:message name="deleteNotificationRequest">
|
|
|
|
<wsdl:part name="uid" type="xsd:string" />
|
|
|
|
<wsdl:part name="myref" type="xsd:string" />
|
|
|
|
</wsdl:message>
|
|
|
|
<wsdl:message name="deleteNotificationResponse">
|
|
|
|
<wsdl:part name="result" type="xsd:int" />
|
|
|
|
</wsdl:message>
|
|
|
|
|
|
|
|
<wsdl:portType name="notificationPortType">
|
|
|
|
<wsdl:operation name="newNotification" parameterOrder="notification">
|
|
|
|
<wsdl:input message="impl:newNotificationRequest" name="newNotificationRequest" />
|
|
|
|
<wsdl:output message="impl:newNotificationResponse" name="newNotificationResponse" />
|
|
|
|
</wsdl:operation>
|
|
|
|
<wsdl:operation name="deleteNotification" parameterOrder="uid myref">
|
|
|
|
<wsdl:input message="impl:deleteNotificationRequest" name="deleteNotificationRequest" />
|
|
|
|
<wsdl:output message="impl:deleteNotificationResponse" name="deleteNotificationResponse" />
|
|
|
|
</wsdl:operation>
|
|
|
|
</wsdl:portType>
|
|
|
|
|
|
|
|
<wsdl:binding name="notificationBinding" type="impl:notificationPortType">
|
|
|
|
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
|
|
|
|
<wsdl:operation name="newNotification">
|
|
|
|
<wsdlsoap:operation soapAction="" />
|
|
|
|
<wsdl:input name="newNotificationRequest">
|
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
|
|
|
</wsdl:input>
|
|
|
|
<wsdl:output name="newNotificationResponse">
|
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
|
|
|
</wsdl:output>
|
|
|
|
</wsdl:operation>
|
|
|
|
<wsdl:operation name="deleteNotification">
|
|
|
|
<wsdlsoap:operation soapAction="" />
|
|
|
|
<wsdl:input name="deleteNotificationRequest">
|
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
|
|
|
</wsdl:input>
|
|
|
|
<wsdl:output name="deleteNotificationResponse">
|
|
|
|
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/PSGI/SOAPService" use="encoded" />
|
|
|
|
</wsdl:output>
|
|
|
|
</wsdl:operation>
|
|
|
|
</wsdl:binding>
|
|
|
|
|
|
|
|
<wsdl:service name="notificationService">
|
|
|
|
<wsdl:port binding="impl:notificationBinding" name="notificationPort">
|
|
|
|
<wsdlsoap:address location="$portal/notifications" />
|
|
|
|
</wsdl:port>
|
|
|
|
</wsdl:service>
|
|
|
|
|
|
|
|
<!-- end notification service -->
|
|
|
|
|
2018-09-25 06:55:17 +02:00
|
|
|
</wsdl:definitions>
|