=> $args->{results}};
# Delete the unassigned fields in this object for a more concise JSON payload
remove_unassigned_fields($self, $args);
bless $self, $class;
return $self;
}
1;
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 ) =
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
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
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;
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
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::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::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
package Lemonldap::NG::Portal::Plugins::Refresh;
use strict;
use Mouse;
use JSON;
our $VERSION = '2.19.0';
extends qw(
Lemonldap::NG::Portal::Main::Plugin
Lemonldap::NG::Portal::Lib::OtherSessi
elf, $req ) = @_;
return $self->p->sendError( $req, 'Not a JSON request', 400 )
unless $req->wantJSON;
my $info = $req->jsonBodyToObj;
return $self->p->sendError( $req, 'Bad content'
ext;
}
my $refreshJSON = $res->[2]->[0];
$self->logger->debug("Refresh result: $refreshJSON");
my $refreshHASH = from_json($refreshJSON);
if ( $refreshHASH->{er
UnauthRoute(
checkentropy => '_checkEntropyJSON',
['POST']
);
$self->addAuthRoute(
checkentropy => '_checkEntropyJSON',
['POST']
);
my $cacheTag = $sel
# Input : request, new user base64-encoded password
# Output: JSON response: { "level" => int, "message" => "msg" }
sub _checkEntropyJSON {
my ( $self, $req, $pass ) = @_;
my $response_params
$self->userLogger->warn("checkEntropy: missing parameter password");
return $self->sendJSONresponse( $req, $response_params );
}
$password = decode_base64($password_base64);
my
:$type: $@");
return 0;
}
$type->import( $self->conf->{oldNotifFormat} ? 'XML' : 'JSON' );
# TODO: use conf database?
my $prms = {
%{ $self->conf->{notificationStorage
or return 0;
}
else {
$self->module( $self->p->loadModule('::Lib::Notifications::JSON') )
or return 0;
}
unless ( eval { $self->module->notifObject( $type->new($prms
q, $ref ) = @_;
$self->p->importHandlerData($req);
if ($ref) {
return $self->sendJSONresponse( $req,
{ error => 'Missing epoch parameter' } )
unless $req->param(
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 } )
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, {
. $mods[$type];
my $over;
if ( $mods[5] ) {
eval { $over = JSON::from_json( $mods[5] ) };
if ($@) {
$self->logger->error("Bad over value (
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, $req ) = @_;
my $response_params;
my $mail_session_id;
# Get json infos
my $infos = $req->jsonBodyToObj
or return $self->p->sendError( $req, undef, 400 );
my $mail
$response_params->{msg} = "InitializePasswordReset: missing parameter";
return $self->sendJSONresponse( $req, $response_params, "code" => 400 );
}
unless ( "$secret" eq $self->initial
ams->{msg} =
"InitializePasswordReset: authentication error";
return $self->sendJSONresponse( $req, $response_params, "code" => 403 );
}
$self->logger->info(
"Initia
legacy OTP mode
package Lemonldap::NG::Portal::2F::Yubikey;
use strict;
use Mouse;
use JSON qw(from_json to_json);
use Lemonldap::NG::Common::Util qw/display2F/;
use Lemonldap::NG::Portal::Main::Cons
their TOTP secret
package Lemonldap::NG::Portal::2F::TOTP;
use strict;
use Mouse;
use JSON qw(from_json to_json);
use Lemonldap::NG::Portal::Main::Constants qw(
PE_OK
PE_ERROR
PE_BADOTP
PE_F
package Lemonldap::NG::Portal::2F::UTOTP;
use strict;
use Mouse;
use JSON qw(from_json to_json);
use Lemonldap::NG::Portal::Main::Constants qw(
);
our $VERSION = '2.0.16';
extends 'Lemonldap::NG::P
# Get a challenge (from first key)
my $data = eval {
from_json(
$req->data->{crypter}->[0]->authenticationChallenge );
};
Token( $token, __ch => $data->{challenge} );
# Serialize data
$data = to_json( {
challenge => $data->{challenge},
appId =