Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LemonLDAP NG
lemonldap-ng
Commits
6eaea508
Commit
6eaea508
authored
Jan 11, 2016
by
Yadd
Browse files
Avoid double utf8 management (
#827
)
parent
1dc99ce8
Changes
20
Hide whitespace changes
Inline
Side-by-side
lemonldap-ng-common/lib/Lemonldap/NG/Common/Apache/Session/Serialize/JSON.pm
View file @
6eaea508
...
...
@@ -2,20 +2,20 @@ package Lemonldap::NG::Common::Apache::Session::Serialize::JSON;
use
strict
;
use
vars
qw($VERSION)
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
our
$VERSION
=
'
1.9.0
';
sub
serialize
{
my
$session
=
shift
;
$session
->
{
serialized
}
=
encode
_json
(
$session
->
{
data
}
);
$session
->
{
serialized
}
=
to
_json
(
$session
->
{
data
}
);
}
sub
unserialize
{
my
$session
=
shift
;
my
$data
=
decode
_json
(
$session
->
{
serialized
}
);
my
$data
=
from
_json
(
$session
->
{
serialized
}
);
die
"
Session could not be unserialized
"
unless
defined
$data
;
$session
->
{
data
}
=
$data
;
}
...
...
@@ -40,8 +40,8 @@ Lemonldap::NG::Common::Apache::Session::Serialize::JSON - Use JSON to zip up dat
=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.
It serializes the data in the session object by use of JSON C<
to
_json>
and C<
from
_json>. The serialized data is UTF-8 text.
=head1 SEE ALSO
...
...
lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/CDBI.pm
View file @
6eaea508
...
...
@@ -2,7 +2,7 @@ package Lemonldap::NG::Common::Conf::CDBI;
use
strict
;
use
utf8
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
Lemonldap::NG::Common::Conf::
_DBI
;
our
$VERSION
=
'
1.4.0
';
...
...
@@ -14,7 +14,7 @@ sub store {
my
$req
;
my
$lastCfg
=
$self
->
lastCfg
;
$fields
=
encode
_json
(
$fields
);
$fields
=
to
_json
(
$fields
);
if
(
$lastCfg
==
$cfgNum
)
{
$req
=
$self
->
_dbh
->
prepare
(
...
...
@@ -47,7 +47,7 @@ sub load {
}
my
$r
;
if
(
$row
->
[
0
]
=~
/^\s*\{/s
)
{
eval
{
$r
=
decode
_json
(
$row
->
[
0
]
);
};
eval
{
$r
=
from
_json
(
$row
->
[
0
]
);
};
}
else
{
# Old format
require
Storable
;
...
...
lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/File.pm
View file @
6eaea508
package
Lemonldap::NG::Common::Conf::
File
;
use
strict
;
use
utf8
;
use
Lemonldap::NG::Common::Conf::
Constants
;
#inherits
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
Encode
;
our
$VERSION
=
'
1.4.0
';
...
...
@@ -23,7 +22,7 @@ sub prereq {
my
$self
=
shift
;
unless
(
$self
->
{
dirName
}
)
{
$
Lemonldap::NG::Common::Conf::
msg
.=
'
"dirName
"
is required in
"
File
"
configuration type ! \n
'
;
"
'
dirName
'
is required in
'
File
'
configuration type !
\n
"
;
return
0
;
}
unless
(
-
d
$self
->
{
dirName
}
)
{
...
...
@@ -89,7 +88,8 @@ sub store {
return
UNKNOWN_ERROR
;
}
binmode
(
FILE
);
print
FILE
JSON
->
new
->
canonical
(
1
)
->
encode
(
$fields
);
my
$f
=
to_json
(
$fields
);
print
FILE
$f
;
close
FILE
;
umask
(
$mask
);
return
$fields
->
{
cfgNum
};
...
...
@@ -107,8 +107,7 @@ sub load {
}
binmode
FILE
;
$f
=
join
(
'',
<
FILE
>
);
$f
=
encode
(
'
UTF-8
',
$f
);
eval
{
$ret
=
decode_json
(
$f
)
};
eval
{
$ret
=
from_json
(
$f
)
};
if
(
$@
)
{
print
STDERR
"
$@
\n
";
$
Lemonldap::NG::Common::Conf::
msg
.=
...
...
lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Serializer.pm
View file @
6eaea508
...
...
@@ -3,7 +3,7 @@ package Lemonldap::NG::Common::Conf::Serializer;
use
strict
;
use
utf8
;
use
Encode
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(JSON to_json from_json)
;
use
Lemonldap::NG::Common::Conf::
Constants
;
our
$VERSION
=
'
1.9.0
';
...
...
@@ -96,7 +96,7 @@ sub unserialize {
unless
(
utf8::
is_utf8
(
$v
)
)
{
$v
=
encode
(
'
UTF-8
',
$v
);
}
$conf
->
{
$k
}
=
(
$v
=~
/./
?
eval
{
decode
_json
(
$v
)
}
:
{}
);
$conf
->
{
$k
}
=
(
$v
=~
/./
?
eval
{
from
_json
(
$v
)
}
:
{}
);
if
(
$@
)
{
$
Lemonldap::NG::Common::Conf::
msg
.=
"
Unable to decode
$k
, probably old format. Trying... ($@)
";
...
...
lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI.pm
View file @
6eaea508
...
...
@@ -2,7 +2,7 @@ package Lemonldap::NG::Common::PSGI;
use
5.10.0
;
use
Mouse
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(JSON to_json from_json)
;
use
Lemonldap::NG::Common::PSGI::
Constants
;
use
Lemonldap::NG::Common::PSGI::
Request
;
...
...
@@ -164,9 +164,9 @@ sub sendHtml {
SCRIPT_NAME
=>
$req
->
scriptname
,
STATIC_PREFIX
=>
$sp
,
AVAILABLE_LANGUAGES
=>
$self
->
languages
,
LINKS
=>
$self
->
links
?
encode
_json
(
$self
->
links
)
:
'
""
',
LINKS
=>
$self
->
links
?
to
_json
(
$self
->
links
)
:
'
""
',
MENULINKS
=>
$self
->
menuLinks
?
encode
_json
(
$self
->
menuLinks
)
?
to
_json
(
$self
->
menuLinks
)
:
'
""
',
VERSION
=>
$VERSION
,
);
...
...
lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Request.pm
View file @
6eaea508
...
...
@@ -2,7 +2,7 @@ package Lemonldap::NG::Common::PSGI::Request;
use
strict
;
use
Mouse
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
URI::
Escape
;
our
$VERSION
=
'
1.9.0
';
...
...
@@ -113,6 +113,7 @@ has CONTENT_LENGTH => (
$self
->
_psgiInput
->
read
(
$self
->
{
body
},
$self
->
{
CONTENT_LENGTH
},
0
);
}
utf8::
upgrade
(
$self
->
{
body
});
}
}
);
...
...
@@ -130,7 +131,7 @@ sub jsonBodyToObj {
return
undef
;
}
return
$self
->
body
if
(
ref
(
$self
->
body
)
);
my
$j
=
eval
{
decode
_json
(
$self
->
body
)
};
my
$j
=
eval
{
from
_json
(
$self
->
body
)
};
if
(
$@
or
$!
)
{
$self
->
error
("
$@$!
");
return
undef
;
...
...
lemonldap-ng-common/t/02-Common-Conf-File.t
View file @
6eaea508
...
...
@@ -55,10 +55,11 @@ for ( my $i = 0 ; $i < @test ; $i++ ) {
my
$cfg
;
ok
(
$cfg
=
$h
->
load
(
1
),
"
Test
$i
can be read
"
)
or
print
STDERR
$
Lemonldap::NG::Common::Conf::
msg
;
ok
(
$cfg
->
{
test
}
eq
$test
[
$i
]
->
{
test
},
"
Test
$i
is restored
"
);
ok
(
$cfg
->
{
test
}
eq
$test
[
$i
]
->
{
test
},
"
Test
$i
is restored
"
)
or
print
STDERR
"
Expect
$cfg
->{test} eq
$test
[
$i
]->{test}
\n
";
$count
+=
2
;
}
unlink
'
t/lmConf-1.js
';
#
unlink 't/lmConf-1.js';
done_testing
(
$count
);
lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli/Lib.pm
View file @
6eaea508
package
Lemonldap::NG::Manager::Cli::
Lib
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
Mouse
;
use
utf8
;
use
Lemonldap::NG::
Manager
;
...
...
@@ -137,7 +137,7 @@ sub jsonResponse {
or
die
"
Manager lib has refused my get, aborting
";
die
"
Manager lib does not return a 200 code, aborting
"
unless
(
$res
->
[
0
]
==
200
);
my
$href
=
decode
_json
(
$res
->
[
2
]
->
[
0
]
)
or
die
'
Response is not JSON
';
my
$href
=
from
_json
(
$res
->
[
2
]
->
[
0
]
)
or
die
'
Response is not JSON
';
return
$href
;
}
...
...
@@ -147,7 +147,7 @@ sub jsonPostResponse {
or
die
"
Manager lib has refused my post, aborting
";
die
"
Manager lib does not return a 200 code, aborting
"
unless
(
$res
->
[
0
]
==
200
);
my
$href
=
decode
_json
(
$res
->
[
2
]
->
[
0
]
)
or
die
'
Response is not JSON
';
my
$href
=
from
_json
(
$res
->
[
2
]
->
[
0
]
)
or
die
'
Response is not JSON
';
return
$href
;
}
...
...
@@ -157,7 +157,7 @@ sub jsonPutResponse {
or
die
"
Manager lib has refused my put, aborting
";
die
"
Manager lib does not return a 200 code, aborting
"
unless
(
$res
->
[
0
]
==
200
);
my
$href
=
decode
_json
(
$res
->
[
2
]
->
[
0
]
)
or
die
'
Response is not JSON
';
my
$href
=
from
_json
(
$res
->
[
2
]
->
[
0
]
)
or
die
'
Response is not JSON
';
return
$href
;
}
...
...
lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf.pm
View file @
6eaea508
...
...
@@ -14,7 +14,6 @@ use Lemonldap::NG::Common::PSGI::Constants;
use
Lemonldap::NG::Manager::
Constants
;
use
Crypt::OpenSSL::
RSA
;
use
Convert::
PEM
;
use
JSON::
MaybeXS
;
use
feature
'
state
';
...
...
lemonldap-ng-manager/t/05-rest-api.t
View file @
6eaea508
...
...
@@ -4,7 +4,7 @@
# Check also metadatas request (root of a conf)
use
Test::
More
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
strict
;
require
'
t/test-lib.pm
';
...
...
@@ -47,7 +47,7 @@ foreach my $query (@bad) {
my
$href
;
#print STDERR Dumper($res->[2]);use Data::Dumper;
ok
(
$href
=
decode
_json
(
$res
->
[
2
]
->
[
0
]
),
'
Response is JSON
'
);
ok
(
$href
=
from
_json
(
$res
->
[
2
]
->
[
0
]
),
'
Response is JSON
'
);
ok
(
$href
->
{
error
},
"
Receive an explanation message (
$href
->{error})
"
);
count
(
3
);
}
...
...
@@ -61,7 +61,7 @@ while (<F>) {
}
close
F
;
ok
(
$hstruct
=
decode
_json
(
$hstruct
),
'
struct.json is JSON
'
);
ok
(
$hstruct
=
from
_json
(
$hstruct
),
'
struct.json is JSON
'
);
ok
(
ref
$hstruct
eq
'
ARRAY
',
'
struct.json is an array
'
);
count
(
2
);
...
...
lemonldap-ng-manager/t/06-rest-api.t
View file @
6eaea508
...
...
@@ -4,7 +4,7 @@
use
Test::
More
;
use
strict
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
IO::
String
;
require
'
t/test-lib.pm
';
...
...
@@ -17,7 +17,7 @@ ok(
);
ok
(
$res
->
[
0
]
==
200
,
"
Result code is 200
"
);
my
$key
;
ok
(
$key
=
decode
_json
(
$res
->
[
2
]
->
[
0
]
),
'
Response is JSON
'
);
ok
(
$key
=
from
_json
(
$res
->
[
2
]
->
[
0
]
),
'
Response is JSON
'
);
count
(
3
);
ok
(
...
...
@@ -28,7 +28,7 @@ ok(
"
Request succeed
"
);
ok
(
$res
->
[
0
]
==
200
,
"
Result code is 200
"
);
ok
(
$key
=
decode
_json
(
$res
->
[
2
]
->
[
0
]
),
'
Response is JSON
'
);
ok
(
$key
=
from
_json
(
$res
->
[
2
]
->
[
0
]
),
'
Response is JSON
'
);
count
(
3
);
#print STDERR Dumper($key);use Data::Dumper;
...
...
lemonldap-ng-manager/t/07-utf8.t
View file @
6eaea508
...
...
@@ -3,14 +3,16 @@
# Test if an UTF-8 char is well returned
use
Test::
More
;
use
JSON::
MaybeXS
;
use
strict
;
use
utf8
;
my
$str
=
"
The LemonLDAP::NG team
\x{c2}\x{a9}
";
require
'
t/test-lib.pm
';
my
$href
=
&client
->
jsonResponse
('
/confs/1/cfgAuthor
');
ok
(
$href
->
{
value
}
eq
"
The LemonLDAP::NG team ©
",
'
Value is well encoded
'
);
#binmode STDERR;
ok
(
$href
->
{
value
}
eq
$str
,
'
Value is well encoded
'
)
or
print
STDERR
"
Expect '
$href
->{value}' eq '
$str
'
";
count
(
1
);
done_testing
(
count
()
);
lemonldap-ng-manager/t/10-save-unchanged-conf.t
View file @
6eaea508
...
...
@@ -4,7 +4,7 @@
use
Test::
More
;
use
strict
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
Data::
Dumper
;
require
'
t/test-lib.pm
';
...
...
@@ -33,7 +33,7 @@ while ( my $body = &body() ) {
);
ok
(
$res
->
[
0
]
==
200
,
"
$desc
: result code is 200
"
);
ok
(
$resBody
=
decode
_json
(
$res
->
[
2
]
->
[
0
]
),
$resBody
=
from
_json
(
$res
->
[
2
]
->
[
0
]
),
"
$desc
: result body contains JSON text
"
);
...
...
lemonldap-ng-manager/t/12-save-changed-conf.t
View file @
6eaea508
...
...
@@ -5,7 +5,7 @@
use
Test::
More
;
use
strict
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
Data::
Dumper
;
require
'
t/test-lib.pm
';
...
...
@@ -23,7 +23,7 @@ my ( $res, $resBody );
ok
(
$res
=
&client
->
_post
(
'
/confs/
',
'
cfgNum=1
',
&body
,
'
application/json
'
),
"
Request succeed
"
);
ok
(
$res
->
[
0
]
==
200
,
"
Result code is 200
"
);
ok
(
$resBody
=
decode
_json
(
$res
->
[
2
]
->
[
0
]
),
ok
(
$resBody
=
from
_json
(
$res
->
[
2
]
->
[
0
]
),
"
Result body contains JSON text
"
);
ok
(
$resBody
->
{
result
}
==
1
,
"
JSON response contains
\"
result:1
\"
"
)
or
print
STDERR
Dumper
(
$resBody
);
...
...
lemonldap-ng-manager/t/40-sessions.t
View file @
6eaea508
...
...
@@ -3,7 +3,7 @@
# Test sessions explorer API
use
Test::
More
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
strict
;
use
Lemonldap::NG::Common::
Session
;
...
...
@@ -147,7 +147,7 @@ foreach (@ids) {
my
$res
;
ok
(
$res
=
&client
->
_del
("
/sessions/global/
$_
"),
"
Delete
$_
"
);
ok
(
$res
->
[
0
]
==
200
,
'
Result code is 200
'
);
ok
(
decode
_json
(
$res
->
[
2
]
->
[
0
]
)
->
{
result
}
==
1
,
ok
(
from
_json
(
$res
->
[
2
]
->
[
0
]
)
->
{
result
}
==
1
,
'
Body is JSON and result==1
'
);
count
(
3
);
}
...
...
lemonldap-ng-manager/t/90-translations.t
View file @
6eaea508
...
...
@@ -3,7 +3,7 @@
# Verify that languages translation cover all `trspan`
use
Test::
More
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
strict
;
my
$langDir
=
'
site/static/languages
';
...
...
@@ -23,7 +23,7 @@ ok( $en = join( '', <F> ), 'en.json is not empty' );
close
F
;
ok
(
@langs
,
'
Found other languages
'
);
my
$keys
;
ok
(
$keys
=
decode
_json
(
$en
),
'
en.json contains JSON
'
);
ok
(
$keys
=
from
_json
(
$en
),
'
en.json contains JSON
'
);
$en
=
undef
;
$count
+=
5
;
...
...
@@ -32,7 +32,7 @@ foreach my $lang (@langs) {
my
$j
;
ok
(
$j
=
join
(
'',
<
F
>
),
"
$lang
is not empty
"
);
my
$l
;
ok
(
$l
=
decode
_json
(
$j
),
"
$lang
contains JSON
"
.
(
$@
?
"
($@)
"
:
""
)
);
ok
(
$l
=
from
_json
(
$j
),
"
$lang
contains JSON
"
.
(
$@
?
"
($@)
"
:
""
)
);
$lang
=~
s/\.json$//
;
my
@l1
=
sort
keys
%$keys
;
my
@l2
=
sort
keys
%$l
;
...
...
lemonldap-ng-portal/example/oauth2.pl
View file @
6eaea508
...
...
@@ -3,7 +3,7 @@
# Simple OpenID Connect client
use
strict
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
LWP::
UserAgent
;
use
MIME::
Base64
qw/encode_base64url encode_base64 decode_base64url decode_base64/
;
...
...
@@ -65,9 +65,9 @@ if ( $cgi->param("test") eq "request" ) {
aud
=>
[
$portal_url
]
};
my
$request_payload
=
encode_base64
(
encode
_json
(
$request_paylod_hash
),
""
);
encode_base64
(
to
_json
(
$request_paylod_hash
),
""
);
my
$request_header_hash
=
{
typ
=>
"
JWT
",
alg
=>
"
HS256
"
};
my
$request_header
=
encode_base64
(
encode
_json
(
$request_header_hash
),
""
);
my
$request_header
=
encode_base64
(
to
_json
(
$request_header_hash
),
""
);
my
$request_digest
=
hmac_sha256_base64
(
$request_header
.
"
.
"
.
$request_payload
,
...
...
@@ -283,7 +283,7 @@ if ($callback) {
my
$content
=
$response
->
decoded_content
;
my
$json
;
eval
{
$json
=
decode
_json
$content
;
};
eval
{
$json
=
from
_json
$content
;
};
if
(
$@
)
{
print
"
<div class=
\"
alert alert-danger
\"
>
";
...
...
@@ -338,7 +338,7 @@ if ($callback) {
# TODO check signature
my
$id_token_payload_hash
=
decode
_json
(
decode_base64
(
$id_token_payload
)
);
my
$id_token_payload_hash
=
from
_json
(
decode_base64
(
$id_token_payload
)
);
print
"
<div class=
\"
panel panel-info
\"
>
\n
";
print
"
<div class=
\"
panel-heading
\"
>
\n
";
...
...
@@ -359,12 +359,12 @@ if ($callback) {
my
$content_type
=
$ui_response
->
header
('
Content-Type
');
if
(
$content_type
=~
/json/
)
{
eval
{
$ui_json
=
decode
_json
(
$ui_content
);
};
eval
{
$ui_json
=
from
_json
(
$ui_content
);
};
}
elsif
(
$content_type
=~
/jwt/
)
{
my
(
$ui_header
,
$ui_payload
,
$ui_signature
)
=
split
(
/\./
,
$ui_content
);
eval
{
$ui_json
=
decode
_json
(
decode_base64
(
$ui_payload
)
);
};
eval
{
$ui_json
=
from
_json
(
decode_base64
(
$ui_payload
)
);
};
}
print
"
<div class=
\"
panel panel-info
\"
>
\n
";
...
...
@@ -436,7 +436,7 @@ elsif ( $cgi->param("test") eq "configuration" ) {
my
$content
=
$config_response
->
decoded_content
;
my
$json
;
eval
{
$json
=
decode
_json
$content
;
};
eval
{
$json
=
from
_json
$content
;
};
if
(
$@
)
{
print
"
<div class=
\"
alert alert-danger
\"
>
";
...
...
@@ -496,7 +496,7 @@ elsif ( $cgi->param("test") eq "configuration" ) {
my
$jwks_content
=
$jwks_response
->
decoded_content
;
my
$jwks_json
;
eval
{
$jwks_json
=
decode
_json
$jwks_content
;
};
eval
{
$jwks_json
=
from
_json
$jwks_content
;
};
if
(
$@
)
{
print
"
<div class=
\"
alert alert-danger
\"
>
";
...
...
@@ -581,7 +581,7 @@ elsif ( $cgi->param("test") eq "registration" ) {
print
"
</div>
\n
";
# POST client metadata
my
$fake_metadata_json
=
encode
_json
(
$fake_metadata
);
my
$fake_metadata_json
=
to
_json
(
$fake_metadata
);
my
$register_response
=
$ua
->
post
(
$registration_uri
,
"
Content-Type
"
=>
'
application/json
',
...
...
@@ -591,7 +591,7 @@ elsif ( $cgi->param("test") eq "registration" ) {
my
$register_content
=
$register_response
->
decoded_content
;
my
$register_json
;
eval
{
$register_json
=
decode
_json
$register_content
;
};
eval
{
$register_json
=
from
_json
$register_content
;
};
if
(
$@
)
{
print
"
<div class=
\"
alert alert-danger
\"
>
";
...
...
@@ -664,9 +664,9 @@ else {
aud
=>
[
$portal_url
]
};
my
$request_payload
=
encode_base64
(
encode
_json
(
$request_paylod_hash
),
""
);
encode_base64
(
to
_json
(
$request_paylod_hash
),
""
);
my
$request_header_hash
=
{
typ
=>
"
JWT
",
alg
=>
"
HS256
"
};
my
$request_header
=
encode_base64
(
encode
_json
(
$request_header_hash
),
""
);
my
$request_header
=
encode_base64
(
to
_json
(
$request_header_hash
),
""
);
my
$request_digest
=
hmac_sha256_base64
(
$request_header
.
"
.
"
.
$request_payload
,
...
...
lemonldap-ng-portal/example/openid-configuration.pl
View file @
6eaea508
#!/usr/bin/perl
use
Lemonldap::NG::Portal::
SharedConf
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
strict
;
my
$portal
=
Lemonldap::NG::Portal::
SharedConf
->
new
();
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthBrowserID.pm
View file @
6eaea508
...
...
@@ -9,7 +9,7 @@ use strict;
use
Lemonldap::NG::Portal::
Simple
;
use
Lemonldap::NG::Portal::
_Browser
;
use
HTTP::
Request
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(JSON to_json from_json)
;
our
@ISA
=
(
qw(Lemonldap::NG::Portal::_Browser)
);
our
$VERSION
=
'
1.3.0
';
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_OpenIDConnect.pm
View file @
6eaea508
...
...
@@ -6,7 +6,7 @@
package
Lemonldap::NG::Portal::
_OpenIDConnect
;
use
strict
;
use
JSON::
MaybeXS
;
use
JSON::
MaybeXS
qw(to_json from_json)
;
use
MIME::
Base64
qw/encode_base64url encode_base64 decode_base64url decode_base64/
;
use
URI::
Escape
;
...
...
@@ -643,7 +643,7 @@ sub decodeJSON {
my
(
$self
,
$json
)
=
@_
;
my
$json_hash
;
eval
{
$json_hash
=
decode
_json
$json
;
};
eval
{
$json_hash
=
from
_json
$json
;
};
if
(
$@
)
{
$json_hash
->
{
error
}
=
"
parse_error
";
...
...
@@ -1228,13 +1228,13 @@ sub createJWT {
my
(
$self
,
$payload
,
$alg
,
$rp
)
=
@_
;
# Payload encoding
my
$jwt_payload
=
encode_base64
(
encode
_json
(
$payload
),
""
);
my
$jwt_payload
=
encode_base64
(
to
_json
(
$payload
),
""
);
# JWT header
my
$jwt_header_hash
=
{
typ
=>
"
JWT
",
alg
=>
$alg
};
$jwt_header_hash
->
{
kid
}
=
$self
->
{
oidcServiceKeyIdSig
}
if
$self
->
{
oidcServiceKeyIdSig
};
my
$jwt_header
=
encode_base64
(
encode
_json
(
$jwt_header_hash
),
""
);
my
$jwt_header
=
encode_base64
(
to
_json
(
$jwt_header_hash
),
""
);
if
(
$alg
eq
"
none
"
)
{
...
...
@@ -1357,7 +1357,7 @@ sub getJWTJSONData {
my
(
$self
,
$jwt
)
=
@_
;
my
$jwt_parts
=
$self
->
extractJWT
(
$jwt
);
return
decode
_json
(
decode_base64url
(
$jwt_parts
->
[
1
]
)
);
return
from
_json
(
decode_base64url
(
$jwt_parts
->
[
1
]
)
);
}
## @method HashRef key2jwks(String key)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment