Commit 7a7bb1fb authored by Clément OUDOT's avatar Clément OUDOT

make tidy on all files

parent a31663cf
......@@ -65,7 +65,7 @@ sub release_all_locks {
my $self = shift;
my $session = shift;
$self->module->release_all_locks($session);
$self->module->release_all_locks($session);
}
1;
......
#######################################################
#
# Lemonldap::NG::Common::Apache::Session::Serialize::JSON
# Serializes session objects using JSON
# Copyright(c) 2015 Xavier Guimard (x.guimard@free.fr)
# Distribute under the GPL2 License
#
#######################################################
package Lemonldap::NG::Common::Apache::Session::Serialize::JSON;
use strict;
use vars qw($VERSION);
use JSON;
our $VERSION = '1.5.99';
sub serialize {
my $session = shift;
$session->{serialized} = encode_json($session->{data});
}
sub unserialize {
my $session = shift;
my $data = decode_json($session->{serialized});
die "Session could not be unserialized" unless defined $data;
$session->{data} = $data;
}
1;
=pod
=head1 NAME
Lemonldap::NG::Common::Apache::Session::Serialize::JSON - Use JSON to zip up data
=head1 SYNOPSIS
use Lemonldap::NG::Common::Apache::Session::Serialize::JSON;
$zipped = Lemonldap::NG::Common::Apache::Session::Serialize::JSON::serialize($ref);
$ref = Lemonldap::NG::Common::Apache::Session::Serialize::JSON::unserialize($zipped);
=head1 DESCRIPTION
This module fulfills the serialization interface of Apache::Session.
It serializes the data in the session object by use of JSON C<encode_json>
and C<decode_json>. The serialized data is UTF-8 text.
=head1 AUTHOR
This module was written by Xavier Guimard <x.guimard@free.fr> using other
Apache::Session serializer written by Jeffrey William Baker <jwbaker@acm.org>.
=head1 SEE ALSO
L<JSON>, L<Apache::Session>
#######################################################
#
# Lemonldap::NG::Common::Apache::Session::Serialize::JSON
# Serializes session objects using JSON
# Copyright(c) 2015 Xavier Guimard (x.guimard@free.fr)
# Distribute under the GPL2 License
#
#######################################################
package Lemonldap::NG::Common::Apache::Session::Serialize::JSON;
use strict;
use vars qw($VERSION);
use JSON;
our $VERSION = '1.5.99';
sub serialize {
my $session = shift;
$session->{serialized} = encode_json( $session->{data} );
}
sub unserialize {
my $session = shift;
my $data = decode_json( $session->{serialized} );
die "Session could not be unserialized" unless defined $data;
$session->{data} = $data;
}
1;
=pod
=head1 NAME
Lemonldap::NG::Common::Apache::Session::Serialize::JSON - Use JSON to zip up data
=head1 SYNOPSIS
use Lemonldap::NG::Common::Apache::Session::Serialize::JSON;
$zipped = Lemonldap::NG::Common::Apache::Session::Serialize::JSON::serialize($ref);
$ref = Lemonldap::NG::Common::Apache::Session::Serialize::JSON::unserialize($zipped);
=head1 DESCRIPTION
This module fulfills the serialization interface of Apache::Session.
It serializes the data in the session object by use of JSON C<encode_json>
and C<decode_json>. The serialized data is UTF-8 text.
=head1 AUTHOR
This module was written by Xavier Guimard <x.guimard@free.fr> using other
Apache::Session serializer written by Jeffrey William Baker <jwbaker@acm.org>.
=head1 SEE ALSO
L<JSON>, L<Apache::Session>
......@@ -116,7 +116,7 @@ sub share_from {
$type = $1 if ( $var = $arg ) =~ s/^(\W)//;
for ( 1 .. 2 ) { # assign twice to avoid any 'used once' warnings
*{$var} =
( !$type ) ? \&{ $pkg . "::$var" }
( !$type ) ? \&{ $pkg . "::$var" }
: ( $type eq '&' ) ? \&{ $pkg . "::$var" }
: ( $type eq '$' ) ? \${ $pkg . "::$var" }
: ( $type eq '@' ) ? \@{ $pkg . "::$var" }
......
......@@ -97,8 +97,8 @@ SKIP: {
$ENV{HTTP_ACCEPT_LANGUAGE} = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3';
ok( ( $cgi2 = Lemonldap::NG::Common::CGI->new() ), 'New CGI' );
ok( $lang = $cgi2->extract_lang(), 'extract_lang' );
ok( $lang->[0] eq 'fr', 'extract_lang' );
ok( $lang->[1] eq 'en', 'extract_lang' );
ok( $lang->[0] eq 'fr', 'extract_lang' );
ok( $lang->[1] eq 'en', 'extract_lang' );
ok( scalar(@$lang) == 2, 'extract_lang' );
# Extract lang Android (See #LEMONLDAP-530)
......@@ -106,8 +106,8 @@ SKIP: {
$ENV{HTTP_ACCEPT_LANGUAGE} = 'fr-FR, en-US';
ok( ( $cgi3 = Lemonldap::NG::Common::CGI->new() ), 'New CGI' );
ok( $lang = $cgi3->extract_lang(), 'extract_lang Android' );
ok( $lang->[0] eq 'fr', 'extract_lang Android' );
ok( $lang->[1] eq 'en', 'extract_lang Android' );
ok( $lang->[0] eq 'fr', 'extract_lang Android' );
ok( $lang->[1] eq 'en', 'extract_lang Android' );
ok( scalar(@$lang) == 2, 'extract_lang Android' );
# SOAP
......
......@@ -29,8 +29,8 @@ ok( 'test..ex.com' !~ HOSTNAME() );
ok( '10.1.1.1' =~ HOST() );
ok( '10.1.1.1' !~ HOSTNAME() );
ok( 'test.ex.com' !~ HTTP_URI() );
ok( 'https://test.ex.com' =~ HTTP_URI() );
ok( 'https://test.ex.com/' =~ HTTP_URI() );
ok( 'https://test.ex.com' =~ HTTP_URI() );
ok( 'https://test.ex.com/' =~ HTTP_URI() );
ok( 'https://test.ex.com/a' =~ HTTP_URI() );
ok( 'https://test.ex.com/?<script>' !~ HTTP_URI() );
......
......@@ -39,7 +39,7 @@ my $gi = $ENV{GATEWAY_INTERFACE};
my $mp = $ENV{MOD_PERL_API_VERSION};
my $mode =
$gi && $gi =~ /^CGI/ ? "CGI"
: $mp && $mp >= 2 ? "ApacheMP2"
: $mp && $mp >= 2 ? "ApacheMP2"
: $mp ? "ApacheMP1"
: $main::{'nginx::'} ? "Nginx"
: "CGI";
......
......@@ -267,7 +267,7 @@ sub run {
{
my $str = $1;
Lemonldap::NG::Handler::Main::Logger->lmLog( 'CDA request', 'debug' );
my $redirectUrl = $class->_buildUrl($uri);
my $redirectUrl = $class->_buildUrl($uri);
my $redirectHttps = ( $redirectUrl =~ m/^https/ );
Lemonldap::NG::Handler::API->set_header_out(
'Location' => $redirectUrl,
......
......@@ -111,7 +111,7 @@ sub share_from {
$type = $1 if ( $var = $arg ) =~ s/^(\W)//;
for ( 1 .. 2 ) { # assign twice to avoid any 'used once' warnings
*{$var} =
( !$type ) ? \&{ $pkg . "::$var" }
( !$type ) ? \&{ $pkg . "::$var" }
: ( $type eq '&' ) ? \&{ $pkg . "::$var" }
: ( $type eq '$' ) ? \${ $pkg . "::$var" }
: ( $type eq '@' ) ? \@{ $pkg . "::$var" }
......
......@@ -1067,8 +1067,8 @@ sub setAuthSessionInfo {
# Extract fields from exportedAttr value
my ( $mandatory, $name, $format, $friendly_name ) =
split( /;/,
$self->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}
->{$_} );
$self->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}->{$_}
);
# Try to get value
my $value =
......
......@@ -1583,8 +1583,8 @@ sub issuerForAuthUser {
my @attributes;
foreach (
keys
%{ $self->{samlSPMetaDataExportedAttributes}->{$spConfKey} } )
keys %{ $self->{samlSPMetaDataExportedAttributes}->{$spConfKey}
} )
{
# Extract fields from exportedAttr value
......
......@@ -44,7 +44,7 @@ sub setSessionInfo {
my %vars = ( %{ $self->{exportedVars} }, %{ $self->{openIdExportedVars} } );
while ( my ( $k, $v ) = each %vars ) {
my $attr = $k;
my $attr = $k;
my $required = ( $attr =~ s/^!// );
if ( $v =~ Lemonldap::NG::Common::Regexp::OPENIDSREGATTR() ) {
$self->{sessionInfo}->{$attr} = $self->param("openid.sreg.$v");
......
......@@ -29,7 +29,7 @@ sub new {
for ( my $i = 0 ; $i < 2 ; $i++ ) {
$stack[$i] =~ s/^Multi\s*//;
foreach my $l ( split /;/, $stack[$i] ) {
$l =~ s/^\s+//; # Remove first space
$l =~ s/^\s+//; # Remove first space
$l =~ /^([\w#]+)(?:\s+(.*))?$/
or $portal->abort( 'Bad configuration', "Unable to read $l" );
my ( $mod, $cond ) = ( $1, $2 );
......
......@@ -1287,7 +1287,7 @@ sub getAttributeValue {
next if ( $name ne $attr_name );
# Verify format and friendly name if given
next if ( $format and $format ne $attr_format );
next if ( $format and $format ne $attr_format );
next if ( $friendly_name and $friendly_name ne $attr_fname );
# Attribute is found, return its content
......
......@@ -39,7 +39,7 @@ my $envData = "127.0.0.1";
$ENV{REMOTE_ADDR} = $envData;
# Real Safe jail
ok( $p->{useSafeJail} == 1, 'Safe jail on' );
ok( $p->{useSafeJail} == 1, 'Safe jail on' );
ok( $p->safe->reval('$uid') eq $sessionData, 'Safe jail on - session data' );
ok( $p->safe->reval('$ENV{REMOTE_ADDR}') eq $envData,
'Safe jail on - env data' );
......@@ -53,7 +53,7 @@ $Lemonldap::NG::Portal::Simple::safe = undef;
$p->{useSafeJail} = 0;
# Fake Safe jail
ok( $p->{useSafeJail} == 0, 'Safe jail off' );
ok( $p->{useSafeJail} == 0, 'Safe jail off' );
ok( $p->safe->reval('$uid') eq $sessionData, 'Safe jail off - session data' );
ok( $p->safe->reval('$ENV{REMOTE_ADDR}') eq $envData,
'Safe jail off - env data' );
......
......@@ -41,8 +41,8 @@ $p3->{error} = 10;
$p3->{lang} = [ 'fr', 'es', 'en' ];
ok( $p1->error() eq $p2->error(10), 'HTTP_ACCEPT_LANGUAGE mechanism 1' );
ok( $p1->error() ne $p2->error(), 'HTTP_ACCEPT_LANGUAGE mechanism 2' );
ok( $p1->error() ne $p3->error(), 'HTTP_ACCEPT_LANGUAGE mechanism 3' );
ok( $p1->error() ne $p2->error(), 'HTTP_ACCEPT_LANGUAGE mechanism 2' );
ok( $p1->error() ne $p3->error(), 'HTTP_ACCEPT_LANGUAGE mechanism 3' );
ok( @en = @{&Lemonldap::NG::Portal::_i18n::msg_en},
'English messages translation' );
......
......@@ -30,26 +30,45 @@ ok(
## JWT Signature verification
# Samples from http://jwt.io
$p->{oidcOPMetaDataOptions}->{jwtio}->{oidcOPMetaDataOptionsClientSecret} = "secret";
$p->{oidcOPMetaDataOptions}->{jwtio}->{oidcOPMetaDataOptionsClientSecret} =
"secret";
my $jwt;
# alg: none
$jwt = "eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOjEyMzQ1Njc4OTAsIm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlfQ.";
ok( $p->verifyJWTSignature("jwtio", $jwt) == 1, 'JWT Signature verification - alg: none');
$jwt =
"eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOjEyMzQ1Njc4OTAsIm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlfQ.";
ok(
$p->verifyJWTSignature( "jwtio", $jwt ) == 1,
'JWT Signature verification - alg: none'
);
# alg: HS256
$jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEyMzQ1Njc4OTAsIm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlfQ.eoaDVGTClRdfxUZXiPs3f8FmJDkDE_VCQFXqKxpLsts";
ok( $p->verifyJWTSignature("jwtio", $jwt) == 1, 'JWT Signature verification - alg: HS256');
$jwt =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEyMzQ1Njc4OTAsIm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlfQ.eoaDVGTClRdfxUZXiPs3f8FmJDkDE_VCQFXqKxpLsts";
ok(
$p->verifyJWTSignature( "jwtio", $jwt ) == 1,
'JWT Signature verification - alg: HS256'
);
# alg: HS512
$jwt = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEyMzQ1Njc4OTAsIm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlfQ.fSCfxDB4cFVvzd6IqiNTuItTYiv-tAp5u5XplJWRDBGNF1rgGn1gyYK9LuHobWWpwqCzI7pEHDlyrbNHaQJmqg";
ok( $p->verifyJWTSignature("jwtio", $jwt) == 1, 'JWT Signature verification - alg: HS512');
$jwt =
"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEyMzQ1Njc4OTAsIm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlfQ.fSCfxDB4cFVvzd6IqiNTuItTYiv-tAp5u5XplJWRDBGNF1rgGn1gyYK9LuHobWWpwqCzI7pEHDlyrbNHaQJmqg";
ok(
$p->verifyJWTSignature( "jwtio", $jwt ) == 1,
'JWT Signature verification - alg: HS512'
);
# Sample from Google
$p->{_oidcOPList}->{google}->{jwks}->{keys}->[0]->{kid} = "3d007677fec656a562826f0191d0f9fcb0e595cf";
$p->{_oidcOPList}->{google}->{jwks}->{keys}->[0]->{n} = "3I_zvpLMNY9UY-SoVm60yh3CRB0LK0CdJ7qqF_Fl07LWNrWSudWSv1q-1QQGwQyxjzuD31eOouqp6gsMgJg6kyECUj9i6zUETCePy3kc-CAPUZE4vj-sJGA0qIcIrI54RdsLL6u27TKAkqqdl-XeO0S5fcUb3AaGW8TpmZoioEU=";
$p->{_oidcOPList}->{google}->{jwks}->{keys}->[0]->{kid} =
"3d007677fec656a562826f0191d0f9fcb0e595cf";
$p->{_oidcOPList}->{google}->{jwks}->{keys}->[0]->{n} =
"3I_zvpLMNY9UY-SoVm60yh3CRB0LK0CdJ7qqF_Fl07LWNrWSudWSv1q-1QQGwQyxjzuD31eOouqp6gsMgJg6kyECUj9i6zUETCePy3kc-CAPUZE4vj-sJGA0qIcIrI54RdsLL6u27TKAkqqdl-XeO0S5fcUb3AaGW8TpmZoioEU=";
$p->{_oidcOPList}->{google}->{jwks}->{keys}->[0]->{e} = "AQAB";
# alg: RS256
$jwt ="eyJhbGciOiJSUzI1NiIsImtpZCI6IjNkMDA3Njc3ZmVjNjU2YTU2MjgyNmYwMTkxZDBmOWZjYjBlNTk1Y2YifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwic3ViIjoiMTE1MzYxMjMwMzU3MzA0NzU0ODQ0IiwiYXpwIjoiMjg2MzA1NzI4NjUyLWxjYW5ubWRnMTdxM2VtdDFjYmtqbmZnOTVzZHM4NjJsLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiZW1haWwiOiJjbGVtZW50QG9vZG8ubmV0IiwiYXRfaGFzaCI6ImZRc0FaSHdsUUNPZXctNE84QkFWNWciLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiYXVkIj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pR6kyctLBXud9A7wyHzJRBCB_rOU12vU4bMWGajgkGUqOmy-PFnz3akvqVgExbqas0Go4Flg7NI";
ok(
$p->verifyJWTSignature( 'google', $jwt ) == 1,
'JWT Signature verification - alg: RS256'
);
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