package Lemonldap::NG::Portal::Lib::Notifications::JSON;
use strict;
use Mouse;
use JSON qw(from_json);
use POSIX qw(strftime);
our $VERSION = '2.21.0';
no warnings 'redefine';
# Lemonldap::NG::Po
my $file ( values %$notifs ) {
my $json = eval { from_json( $file, { allow_nonref => 1 } ) };
$self->userLogger->warn(
"Bad JSON file: a notification for $uid was not done
@);
my $j = 0; # Notifications count
$json = [$json] unless ( ref $json eq 'ARRAY' );
LOOP: foreach my $notif ( @{$json} ) {
# Get the reference
my $r
p::NG::Portal::Plugins::OidcOfflineTokens;
use strict;
use Mouse;
use Date::Parse;
use JSON qw(from_json to_json);
use Time::Local;
use Lemonldap::NG::Portal::Main::Constants qw(
PE_OK
PE_ERROR
$req,
"oidcOfflineTokens",
params => {
sessions => to_json($activeSessions),
js =>
"$self->{p}->{staticPrefix}/commo
session $id");
$session->remove( {
hashStore => 0
}
);
#TODO : Call BackChannelLogout if needed
return $self->p->sendJSONresponse( $req, { result => 1 } );
}
1;
decode_jwt);
use Digest::SHA qw/sha1 hmac_sha256_base64 sha256 sha384 sha512 sha256_base64/;
use JSON;
use Lemonldap::NG::Common::FormEncode;
use Lemonldap::NG::Common::OpenIDConnect::Constants;
use
ity provider in configuration
unless ( $self->conf->{oidcOPMetaDataJSON}
and keys %{ $self->conf->{oidcOPMetaDataJSON} } )
{
$self->logger->warn(
"No OpenID Connect
;
}
# Extract JSON data
foreach ( keys %{ $self->conf->{oidcOPMetaDataJSON} } ) {
my $op_conf =
$self->decodeJSON( $self->conf->{oidcOPMetaDataJSON}->{$_} );
if
package Lemonldap::NG::Portal::Lib::RESTProxy;
use strict;
use JSON;
use Mouse;
use Lemonldap::NG::Common::UserAgent;
use Lemonldap::NG::Portal::Main::Constants qw(
URIRE
PE_OK
PE_ERROR
PE_BA
G::Common::UserAgent->new( $self->conf ) );
$self->ua->default_header( Accept => 'application/json' );
$self->cookieName( $self->conf->{proxyCookieName}
|| $self->conf->{cookieName}
turn PE_ERROR;
}
$self->logger->debug('Proxy gets a response');
my $res = eval { JSON::from_json( $resp->content, { allow_nonref => 1 } ) };
if ($@) {
$self->logger->error("Bad
G::Portal::Lib::REST;
use strict;
use Mouse;
use Lemonldap::NG::Common::UserAgent;
use JSON qw(from_json to_json);
our $VERSION = '2.0.6';
has ua => (
is => 'rw',
lazy => 1,
def
application/json' );
$hreq->content( to_json($content) );
my $resp = $self->ua->request($hreq);
die $resp->status_line unless $resp->is_success;
my $res = eval { from_json( $resp->con
tent ) };
die "Bad REST response: $@" if ($@);
if ( ref($res) ne "HASH" ) {
die "Bad REST response: expecting a JSON HASH, got " . ref($res);
}
return $res;
}
1;
SMTP common functions
package Lemonldap::NG::Portal::Lib::SMTP;
use strict;
use Mouse;
use JSON qw(from_json);
use MIME::Entity;
use Lemonldap::NG::Common::EmailAddress qw(format_email);
use Email::S
my $json = $self->conf->{templateDir} . "/common/mail/$lang_code.json";
$json = $self->conf->{templateDir} . '/common/mail/en.json'
unless ( -f $json );
open F, '<', $json
code.json or $self->{conf}->{templateDir}/common/mail/en.json)";
$json = join '', <F>;
close F;
my $lang = from_json( $json, { allow_nonref => 1 } );
my $langOver =
from_json( $s
ict;
use Mouse::Role;
use MIME::Base64 qw(encode_base64url decode_base64url);
use JSON qw(decode_json from_json to_json);
use Digest::SHA qw(sha256);
use URI;
use Carp;
with 'Lemonldap::NG::Portal::Li
id} = $appid;
}
$self->logger->debug(
"WebAuthn authentication parameters " . to_json($challenge) );
return $challenge;
}
sub _formatCredentialForRequest {
my ( $self, $cred
sicChallenge($req);
$self->logger->debug(
"WebAuthn authentication parameters " . to_json($challenge) );
return $challenge;
}
sub _generateBasicChallenge {
my ( $self, $req ) =
ODS
=over
=cut
use strict;
use Mouse::Role;
use Lemonldap::NG::Common::Util qw/display2F/;
use JSON;
requires qw(p conf logger);
our $VERSION = '2.21.0';
=item update2fDevice
Updates one field
if (@found) {
$self->p->updatePersistentSession( $req,
{ _2fDevices => to_json($_2fDevices) }, $user );
return 1;
}
return 0;
}
=item add2fDevice
Store a new
isplay2F($device),
);
$self->p->updatePersistentSession( $req,
{ _2fDevices => to_json($_2fDevices) } );
return 1;
}
=item del2fDevices
Delete the devices specified in the @$devi
package Lemonldap::NG::Portal::Plugins::GlobalLogout;
use strict;
use Mouse;
use JSON qw(from_json to_json);
use Time::Local;
use Lemonldap::NG::Common::Session 'id2storage';
use Lemonldap::NG::Porta
my $token = $self->ott->createToken( {
user => $user,
sessions => to_json($sessions)
}
);
# Prepare form
$self->logger->debug("Prepare global logout c
f->{globalLogoutCustomParam}
}
);
$req->response(
$req->wantJSON
? $self->sendJSONresponse( $req,
{ globalLogout => $nbr, confirmationRequired => 1 } )
splay;
our $VERSION = '2.22.0';
package Lemonldap::NG::Portal::Main;
use strict;
use Mouse;
use JSON;
use URI;
has speChars => ( is => 'rw' );
has skinRules => ( is =
s;
if ( exists $session->{_oidcConsents} ) {
$_oidcConsents = eval {
from_json( $session->{_oidcConsents}, { allow_nonref => 1 } );
};
if ($@) {
$se
PPOLICY_ALLOWEDSPECHAR => $self->speChars(),
PPOLICY_ALLOWEDSPECHAR_JSON =>
to_json( $self->speChars(), { allow_nonref => 1 } ),
)
: ()
$self->conf->{$k} = $self->localConfig->{$k};
}
}
$self->trOver( JSON::to_json( $self->trOver ) );
# Purge loaded module list
$self->_resetPluginsAndServices;
package Lemonldap::NG::Portal::Lib::OneTimeToken;
use strict;
use Mouse;
use JSON qw(from_json to_json);
use Crypt::URandom;
our $VERSION = '2.22.0';
extends 'Lemonldap::NG::Common::Module';
has t
m(2) );
# Dereference $infos
my %h = %$infos;
$self->cache->set( $id, to_json( \%h ), $self->timeout . ' s' );
$self->logger->debug("Token $id created");
retur
return undef;
}
$self->cache->remove($id) unless ($keep);
return from_json( $data, { allow_nonref => 1 } );
}
else {
# Get token session
my $tsessi
. $mods[$type];
my $over;
if ( $mods[5] ) {
eval { $over = JSON::from_json( $mods[5] ) };
if ($@) {
$self->logger->error("Bad over value (
package Lemonldap::NG::Portal::Password::REST;
use strict;
use Mouse;
use JSON;
use Lemonldap::NG::Portal::Main::Constants qw(
PE_ERROR
PE_PASSWORD_OK
);
extends qw(
Lemonldap::NG::Portal::Lib
{useMail} ? 'mail' : 'user' ) => $req->user,
useMail => ( $args{useMail} ? JSON::true : JSON::false ),
password => $pwd
}
);
};
if ($@) {
package Lemonldap::NG::Portal::Plugins::CheckDevOps;
use strict;
use Mouse;
use JSON qw(from_json);
use Lemonldap::NG::Common::UserAgent;
use Lemonldap::NG::Common::Util qw(isHiddenAttr);
use Lemonld
->ott->createToken()
: ''
)
};
return $self->sendJSONresponse( $req, $params ) if $req->wantJSON;
# Display form
return $self->p->sendHtml( $req, 'checkdevops', pa
$req ) = @_;
my ( $headers, $rules, $unknown ) = ( [], [], [] );
my ( $msg, $json, $url, $bad_json );
my $alert = 'alert-danger';
# Check token
if ( $self->ottRule->( $req, {
er->debug('Initialize Kerberos dialog');
# Case 1.1: Ajax request
if ( $req->wantJSON ) {
$req->response( [
401,
[
'WWW-Authenticate' => 'Negotiate',
'Content-Type' => 'application/json',
'Content-Length' => 35
],
['{
[
'WWW-Authenticate' => 'Negotiate',
'Content-Type' => 'application/json',
'Content-Length' => 35
],
['{"error":"Authentication required"}']
# by category
package Lemonldap::NG::Portal::Plugins::Status;
use strict;
use Mouse;
use JSON qw(from_json);
use MIME::Base64;
use IO::Socket::INET;
our $VERSION = '2.0.10';
extends 'Lemonldap::N
int("STATUS json=1$args\n");
while ( $_ = $out->getline ) {
last if (/^END$/);
$buf .= $_;
}
if ($buf) {
eval { $res = from_json( $buf, { al
1 } ) };
if ($@) {
$self->logger->error("JSON error: $@");
$self->logger->error("JSON: $buf");
}
foreach (qw(total average)) {
new user password, flag noJSONResponse
# Output: JSON response, including a code.
# code = 0 = success
# code > 0 = error
sub _checkHIBP {
my ( $self, $req, $pass, $noJSONResponse ) = @_;
my $
sage"} = "missing parameter password";
return $noJSONResponse
? $response_params
: $self->sendJSONresponse( $req, $response_params );
}
$passwo
mpromised $num times";
return $noJSONResponse
? $response_params
: $self->sendJSONresponse( $req, $response_params );
}
package Lemonldap::NG::Portal::UserDB::REST;
use strict;
use Mouse;
use JSON qw(from_json to_json);
use Lemonldap::NG::Portal::Main::Constants qw(
PE_OK
PE_ERROR
PE_USERNOTFOUND
PE_BADCREDENT
useMail} ? 'mail' : 'user' ) => $req->user,
'useMail' => ( $args{useMail} ? JSON::true : JSON::false ),
}
);
};
if ($@) {
$self->logger->error("Use
searchingAttributes => to_json($searching),
(
scalar @$excluding
? ( excludingAttributes => to_json($excluding) )
rtal::Plugins::MailPasswordReset;
use strict;
use Encode;
use Mouse;
use POSIX qw(strftime);
use JSON;
use Lemonldap::NG::Common::FormEncode;
use Lemonldap::NG::Portal::Main::Constants qw(
PE_OK