Commit 18004978 authored by Xavier Guimard's avatar Xavier Guimard

LEMONLDAP::NG : propagation of 0.9.3.4 changes

parent 26492b57
......@@ -11,7 +11,7 @@ Licence:
Lemonldap::NG is distributed under your choice under the GNU General Public
License or the Artistic License.
On Debian GNU/Linux systems, the complete text of the GNU General Public
License version 2 can be found in `/usr/share/common-licenses/GPL' and the
License version 2 can be found in `/usr/share/common-licenses/GPL-2' and the
Artistic Licence in `/usr/share/common-licenses/Artistic'.
File lemonldap-ng-manager/example/lemonldap-ng-manager.js is distributed under
......
......@@ -5,6 +5,7 @@ lib/Lemonldap/NG/Common/Apache/Session/SOAP.pm
lib/Lemonldap/NG/Common/BuildWSDL.pm
lib/Lemonldap/NG/Common/CGI.pm
lib/Lemonldap/NG/Common/CGI/SOAPServer.pm
lib/Lemonldap/NG/Common/CGI/SOAPService.pm
lib/Lemonldap/NG/Common/Conf.pm
lib/Lemonldap/NG/Common/Conf/Constants.pm
lib/Lemonldap/NG/Common/Conf/DBI.pm
......
......@@ -16,23 +16,21 @@ our $VERSION = '0.31';
use base qw(CGI);
## @method void soapTest(string soapFunctions)
## @method void soapTest(string soapFunctions object obj)
# Check if request is a SOAP request. If it is, launch
# Lemonldap::NG::Common::CGI::SOAPServer and exit. Else simply return.
# @param $soapFunctions list of authorized functions.
# @param $obj optional object that will receive SOAP requests
sub soapTest {
my $self = shift;
my $soapFunctions = shift || $self->{SOAPFunctions};
my($self, $soapFunctions, $obj) = @_;
# If non form encoded datas are posted, we call SOAP Services
if ( $ENV{HTTP_SOAPACTION} ) {
require Lemonldap::NG::Common::CGI::SOAPServer;
my @func = ();
foreach ( ref($soapFunctions) ? @$soapFunctions : split /\s+/, $soapFunctions ) {
$_ = ref($self) . "::$_" unless (/::/);
push @func, $_;
}
Lemonldap::NG::Common::CGI::SOAPServer->dispatch_to(@func)
require Lemonldap::NG::Common::CGI::SOAPServer; #link protected dispatcher
require Lemonldap::NG::Common::CGI::SOAPService; #link protected soapService
my @func = ( ref($soapFunctions) ? @$soapFunctions : split /\s+/, $soapFunctions );
my $dispatcher = Lemonldap::NG::Common::CGI::SOAPService->new($obj||$self,@func);
Lemonldap::NG::Common::CGI::SOAPServer->dispatch_to($dispatcher)
->handle($self);
exit;
}
......
......@@ -63,7 +63,7 @@ sub handle {
$content,
)
);
$self->SUPER::handle;
$self->SUPER::handle();
}
print $cgi->header(
......
## @file
# SOAP wrapper used to restrict exported functions
## @class
# SOAP wrapper used to restrict exported functions
package Lemonldap::NG::Common::CGI::SOAPService;
## @cmethod Lemonldap::NG::Common::CGI::SOAPService new(object obj,string @func)
# Constructor
# @param $obj object which will be called for SOAP authorizated methods
# @param @fung authorizated methods
# @return Lemonldap::NG::Common::CGI::SOAPService object
sub new {
my($class, $obj, @func) = @_;
s/.*::// foreach(@func);
return bless {obj=>$obj,func=>\@func}, $class;
}
## @method datas AUTOLOAD()
# Call the wanted function with the object given to the constructor.
# AUTOLOAD() is a magic method called by Perl interpreter fon non existent
# functions. Here, we use it to call the wanted function (given by $AUTOLOAD)
# if it is authorizated
# @return datas provided by the exported function
sub AUTOLOAD {
my $self = shift;
$AUTOLOAD =~ s/.*:://;
if(grep {$_ eq $AUTOLOAD} @{$self->{func}}){
return $self->{obj}->$AUTOLOAD(@_);
}
elsif($AUTOLOAD ne 'DESTROY') {
die "$AUTOLOAD is an authorizated function";use Data::Dumper;
}
1;
}
1;
......@@ -25,7 +25,7 @@ print Lemonldap::NG::Common::BuildWSDL->new->buildWSDL(<<EOT);
<wsdl:part name="lang" type="xsd:string" />
<wsdl:part name="code" type="xsd:int" />
</wsdl:message>
<wsdl:message name="errorResponse">
<wsdl:message name="errorResponse">
<wsdl:part name="errorReturn" type="xsd:string" />
</wsdl:message>
<wsdl:message name="getCookiesRequest">
......
......@@ -75,7 +75,7 @@ SOAP mode authentication (client) :
my $soap =
SOAP::Lite->proxy('http://auth.example.com/')
->uri('urn:/Lemonldap::NG::Portal::SharedConf');
->uri('urn:/Lemonldap::NG::Common::::CGI::SOAPService');
my $r = $soap->getCookies( 'user', 'password' );
# Catch SOAP errors
......
......@@ -123,7 +123,7 @@ SOAP mode authentication (client) :
my $soap =
SOAP::Lite->proxy('http://auth.example.com/')
->uri('urn:/Lemonldap::NG::Portal::SharedConf');
->uri('urn:/Lemonldap::NG::Common::::CGI::SOAPService');
my $r = $soap->getCookies( 'user', 'password' );
# Catch SOAP errors
......
......@@ -95,7 +95,7 @@ sub new {
binmode( STDOUT, ":utf8" );
my $class = shift;
return $class if ( ref($class) );
$self = $class->SUPER::new();
my $self = $class->SUPER::new();
$self->getConf(@_)
or $self->abort( "Configuration error",
"Unable to get configuration: $Lemonldap::NG::Common::Conf::msg" );
......@@ -158,7 +158,7 @@ sub new {
if ( $self->{notification} and $ENV{PATH_INFO} and $ENV{PATH_INFO} =~ "/notification" ) {
require SOAP::Lite;
$Lemonldap::NG::Portal::Notification::self = $self->{notifObject};
$self->soapTest('Lemonldap::NG::Portal::Notification::newNotification');
$self->soapTest('Lemonldap::NG::Portal::Notification::newNotification',$self->{notifObject});
$self->abort('Bad request', 'Only SOAP requests are accepted with "/notification"');
}
if ( $self->{Soap} ) {
......@@ -450,7 +450,7 @@ sub safe {
}";
print STDERR $@ if ($@);
}
$safe->share( '$self', '&encode_base64', @t );
$safe->share( '&encode_base64', @t );
return $safe;
}
......@@ -475,7 +475,7 @@ _RETURN $getCookieResponse Response
#@param password password
#@return session => { error => code , cookies => { cookieName1 => value ,... } }
sub getCookies {
my $class = shift;
my $self = shift;
$self->{error} = PE_OK;
( $self->{user}, $self->{password} ) = ( shift, shift );
unless ( $self->{user} && $self->{password} ) {
......@@ -549,7 +549,7 @@ sub controlUrlOrigin {
if (
$self->{urldc} =~ /(?:\0|<|'|"|`|\%(?:00|25|3C|22|27|2C))/
or ( $self->{urldc} !~
m#^https?://(?:$self->{reVHosts}|(?:[^/]*)?$self->{domain})(?:/.*)?$#
m#^https?://(?:$self->{reVHosts}|(?:[^/]*)?$self->{domain})(?::\d+)?(?:/.*)?$#
and not $self->param('logout') )
)
{
......@@ -698,6 +698,7 @@ sub setMacros {
local $self = shift;
$self->abort( __PACKAGE__ . ": Unable to get configuration" )
unless ( $self->getConf(@_) );
$self->safe->share('$self');
while ( my ( $n, $e ) = each( %{ $self->{macros} } ) ) {
$e =~ s/\$(\w+)/\$self->{sessionInfo}->{$1}/g;
$self->{sessionInfo}->{$n} = $self->safe->reval($e);
......@@ -713,12 +714,9 @@ sub setMacros {
sub setGroups {
local $self = shift;
my $groups;
#foreach ( keys %{ $self->{groups} } ) {
$self->safe->share('$self');
while ( my ( $group, $expr ) = each %{ $self->{groups} } ) {
$expr =~ s/\$(\w+)/\$self->{sessionInfo}->{$1}/g;
# TODO : custom Functions
$groups .= "$group " if ( $self->safe->reval($expr) );
}
if ( $self->{ldapGroupBase} ) {
......@@ -919,7 +917,7 @@ SOAP mode authentication (client) :
my $soap =
SOAP::Lite->proxy('http://auth.example.com/')
->uri('urn:/Lemonldap::NG::Portal::SharedConf');
->uri('urn:/Lemonldap::NG::Common::::CGI::SOAPService');
my $r = $soap->getCookies( 'user', 'password' );
# Catch SOAP errors
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment