Commit 293f0eea authored by Xavier Guimard's avatar Xavier Guimard

Replace build_urlencode to manage old Plack (#595)

parent e17333aa
......@@ -23,9 +23,11 @@ lib/Lemonldap/NG/Common/Conf/Backends/RDBI.pm
lib/Lemonldap/NG/Common/Conf/Backends/SOAP.pm
lib/Lemonldap/NG/Common/Conf/Constants.pm
lib/Lemonldap/NG/Common/Conf/DefaultValues.pm
lib/Lemonldap/NG/Common/Conf/RESTServer.pm
lib/Lemonldap/NG/Common/Conf/SAML/Metadata.pm
lib/Lemonldap/NG/Common/Conf/Serializer.pm
lib/Lemonldap/NG/Common/Crypto.pm
lib/Lemonldap/NG/Common/FormEncode.pm
lib/Lemonldap/NG/Common/Module.pm
lib/Lemonldap/NG/Common/Notifications.pm
lib/Lemonldap/NG/Common/Notifications/DBI.pm
......
package Lemonldap::NG::Common::FormEncode;
use strict;
use Exporter;
our @ISA = qw(Exporter);
our $VERSION = '2.0.0';
our @EXPORT_OK = qw(build_urlencoded);
our @EXPORT = qw(build_urlencoded);
BEGIN {
require Plack::Request;
if ( $Plack::Request::VERSION < '1.0040' ) {
require URI::Escape;
eval <<'EOT';
sub build_urlencoded {
my(%h)=@_;
my $v;
return join('&',map {$v=URI::Escape::uri_escape($h{$_});"$_=$v"} keys %h);
}
EOT
}
else {
require WWW::Form::UrlEncoded;
eval <<'EOT';
sub build_urlencoded {
return WWW::Form::UrlEncoded::build_urlencoded(@_);
}
EOT
}
}
1;
......@@ -70,11 +70,11 @@ lib/Lemonldap/NG/Portal/Lib/LDAP.pm
lib/Lemonldap/NG/Portal/Lib/OpenID/Server.pm
lib/Lemonldap/NG/Portal/Lib/OpenID/SREG.pm
lib/Lemonldap/NG/Portal/Lib/OpenIDConnect.pm
lib/Lemonldap/NG/Portal/Lib/Proxy.pm
lib/Lemonldap/NG/Portal/Lib/Remote.pm
lib/Lemonldap/NG/Portal/Lib/SAML.pm
lib/Lemonldap/NG/Portal/Lib/Slave.pm
lib/Lemonldap/NG/Portal/Lib/SMTP.pm
lib/Lemonldap/NG/Portal/Lib/SOAPProxy.pm
lib/Lemonldap/NG/Portal/Lib/Wrapper.pm
lib/Lemonldap/NG/Portal/MailReset.pm
lib/Lemonldap/NG/Portal/Main.pm
......
......@@ -2,7 +2,7 @@ package Lemonldap::NG::Portal::Auth::OpenID;
use strict;
use Mouse;
use WWW::Form::UrlEncoded qw/build_urlencoded/;
use Lemonldap::NG::Common::FormEncode;
use Lemonldap::NG::Common::Regexp;
use Cache::FileCache;
use Lemonldap::NG::Portal::Main::Constants qw(
......
......@@ -12,10 +12,10 @@ use Digest::SHA
qw/hmac_sha256_base64 hmac_sha384_base64 hmac_sha512_base64 sha256 sha384
sha512 sha256_base64 sha384_base64 sha512_base64/;
use JSON;
use Lemonldap::NG::Common::FormEncode;
use LWP::UserAgent;
use MIME::Base64 qw/encode_base64 decode_base64/;
use Mouse;
use WWW::Form::UrlEncoded qw/build_urlencoded/;
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_REDIRECT);
......@@ -320,8 +320,8 @@ sub buildAuthorizationCodeAuthnResponse {
# @param session_state Session state
# return String Authentication Response URI
sub buildImplicitAuthnResponse {
my ( $self, $redirect_uri, $access_token, $id_token, $expires_in, $state,
$session_state )
my ( $self, $redirect_uri, $access_token, $id_token, $expires_in,
$state, $session_state )
= @_;
my $response_url = "$redirect_uri#"
......@@ -588,7 +588,8 @@ sub checkIDTokenValidity {
sub getUserInfo {
my ( $self, $op, $access_token ) = @_;
my $userinfo_uri = $self->oidcOPList->{$op}->{conf}->{userinfo_endpoint};
my $userinfo_uri =
$self->oidcOPList->{$op}->{conf}->{userinfo_endpoint};
unless ($userinfo_uri) {
$self->lmLog( "UserInfo URI not found in $op configuration", 'error' );
......@@ -1058,7 +1059,8 @@ sub getEndPointAuthenticationCredentials {
if ( $authorization and $authorization =~ /^Basic (\w+)/i ) {
$self->lmLog( "Method client_secret_basic used", 'debug' );
eval {
( $client_id, $client_secret ) = split( /:/, decode_base64($1) );
( $client_id, $client_secret ) =
split( /:/, decode_base64($1) );
};
$self->lmLog( "Bad authentication header: $@", 'error' ) if ($@);
}
......@@ -1344,7 +1346,8 @@ sub buildLogoutResponse {
sub createSessionState {
my ( $self, $session_id, $client_id ) = @_;
my $salt = encode_base64url( $self->conf->{cipher}->encrypt($client_id) );
my $salt =
encode_base64url( $self->conf->{cipher}->encrypt($client_id) );
my $data = $client_id . " " . $session_id . " " . $salt;
my $hash = sha256_base64($data);
......
......@@ -14,7 +14,6 @@ our $VERSION = '2.0.0';
package Lemonldap::NG::Portal::Main;
use strict;
use WWW::Form::UrlEncoded 'build_urlencoded';
# List constants
sub authProcess { qw(extractFormInfo getUser authenticate) }
......
......@@ -175,7 +175,7 @@ sub mysession {
# 1. whoami
if ( defined $req->param('whoami') ) {
return $self->p->sendJSONresponse( $res,
return $self->p->sendJSONresponse( $req,
{ result => $req->sessionInfo->{ $self->conf->{whatToTrace} } } );
}
......
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