ldap::NG::Portal::Plugins::SingleSession;
use strict;
use Mouse;
use MIME::Base64;
use JSON qw(from_json to_json);
use Lemonldap::NG::Common::Session 'id2storage';
use Lemonldap::NG::Portal::Main::Co
user => $req->{sessionInfo}->{ $self->conf->{whatToTrace} },
sessions => to_json( \@otherSessionsId )
}
) if @otherSessionsId;
if ($singleUserByIPRuleMatched) {
tToken($token) ) {
# Read sessions from token
my $sessions = eval { from_json( $token->{sessions} ) };
if ($@) {
$self->logger->error("Bad encoding
$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
:$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::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
REST requests directly by using '/' path : the portal recognize REST
# calls and generate JSON response instead of web page.
#
# - Configuration (if restConfigServer is on)
# * GET /config/l
T /error/<lang>/<errNum> : get <errNum> message reference and errors file <lang>.json
# Return 'en' error file if no <lang> specified
#
# - Endpoints for proxy auth/userdb/password
gether
package Lemonldap::NG::Portal::Plugins::RESTServer;
use strict;
use Mouse;
use JSON qw(from_json to_json);
use MIME::Base64;
use Lemonldap::NG::Common::Languages;
use Lemonldap::NG::Common::S
SION = '2.22.0';
package Lemonldap::NG::Portal::Main;
use strict;
use URI::Escape;
use URI;
use JSON;
use Lemonldap::NG::Common::Util qw(getPSessionID getSameSite);
has trOverCache => ( is => 'rw',
) {
$sp = 1;
eval { $req->pdata( JSON::from_json( uri_unescape($v) ) ); };
if ($@) {
$self->logger->error("Bad JSON content in cookie pdata");
$req->pda
secure => $self->conf->{securedCookie},
value => uri_escape( JSON::to_json( $req->pdata ) ),
%pdata_options,
);
}
else {
package Lemonldap::NG::Portal::Auth::GitHub;
use strict;
use JSON;
use Mouse;
use MIME::Base64 qw/encode_base64 decode_base64/;
use Lemonldap::NG::Common::FormEncode;
use Lemonldap::NG::Common::UserA
"Content-Type" => 'application/x-www-form-urlencoded',
'Accept' => 'application/json'
);
if ( $response->is_error ) {
$self->logger->error(
tent;
my $json_hash;
eval { $json_hash = from_json( $content, { allow_nonref => 1 } ); };
if ($@) {
$self->logger->error("Unable to decode JSON $content");
package Lemonldap::NG::Portal::Plugins::PublicNotifications;
use strict;
use JSON;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw(
PE_OK
PE_ERROR
);
our $VERSION = '2.22.0';
extends '
# - $self->notifObject->module : librarie depending on chosen format
# (Notifications::JSON or Notifications::XML)
# - $self->notifObject->module->notifObject : Common::Notification
rrors = [ map { from_json( $errors->{$_} ) } keys %$errors ];
my $public_warns = [ map { from_json( $warns->{$_} ) } keys %$warns ];
my $public_infos = [ map { from_json( $infos->{$_} ) } ke
::2F::Engines::Default;
use strict;
use Mouse;
use MIME::Base64 qw(encode_base64);
use JSON qw(from_json to_json);
use POSIX qw(strftime);
use Lemonldap::NG::Portal::Main::Constants qw(
PE_OK
PE_
m;
# After verifying rule:
# - call register run method if $prefix
# - else give JSON list of available registers for this user
if ($prefix) {
my ($m) =
grep { $
url => "/2fregisters/$name"
};
}
}
return $self->p->sendJSONresponse( $req, \@am );
}
sub restoreSession {
my ( $self, $req, @path ) = @_;
if ( my $
a->default_headers->header( 'Accept' => 'application/json' );
$ua->default_headers->header( 'Content-Type' => 'application/json' );
$ua->default_headers->header(
'Aut
Extra
package Lemonldap::NG::Portal::2F::Register::Generic;
use strict;
use Mouse;
use JSON qw(from_json to_json);
use Lemonldap::NG::Common::Crypto;
use Lemonldap::NG::Portal::Main::Constants 'PE_OK
package Lemonldap::NG::Portal::Issuer::JitsiMeetTokens;
use strict;
use URI;
use Mouse;
use JSON;
use MIME::Base64 qw/decode_base64url encode_base64url/;
use Crypt::JWT qw(encode_jwt);
use Digest::
$key = \$private;
}
my $jwt = eval {
encode_jwt(
payload => to_json($payload),
alg => $self->jitsi_signing_alg,
key => $k
package Lemonldap::NG::Portal::2F::Okta;
use HTTP::Request;
use JSON;
use Mouse;
use URI;
use Lemonldap::NG::Common::UserAgent;
use Lemonldap::NG::Portal::Main::Constants qw(
PE_OK
PE_BADCREDENTI
"Get poll response for $okta_userid:" . $poll_response );
$poll_content = $self->decodeJSON($poll_response);
$okta_poll_result = $poll_content->{factorResult};
unless ( $o
or $okta_userid:"
. $verify_factor_response );
my $okta_verification = $self->decodeJSON($verify_factor_response);
unless ( $okta_verification->{factorResult} eq "SUCCESS" ) {
$captcha_input,
}
);
if ( $response->is_success ) {
my $res = eval { JSON::from_json( $response->decoded_content ) };
if ($@) {
$self->logger->error("reCapt
::TOTP;
use strict;
use Lemonldap::NG::Portal::Main::Constants 'PE_OK';
use Mouse;
use JSON qw(from_json to_json);
our $VERSION = '2.21.0';
extends qw(
Lemonldap::NG::Portal::2F::Register::Base
for the tab
=item C<name>: user-displayed name of the tab, which should be translated in I<lang>.json files.
=item C<id>: HTML element id for the tab, must be unique
=item C<html>: HTML content of
$captcha_input,
}
);
if ( $response->is_success ) {
my $res = eval { JSON::from_json( $response->decoded_content ) };
if ($@) {
$self->logger->error("reCapt
package Lemonldap::NG::Portal::Auth::WebAuthn;
use strict;
use Mouse;
use JSON;
use Lemonldap::NG::Portal::Main::Constants qw(
PE_ERROR
PE_WEBAUTHNFAILED
PE_FIRSTACCESS
PE_SENDRESPONSE
PE_T
= @_;
my $request = $self->get_challenge($req);
if ($request) {
my $data = to_json( {
request => $request,
webauthn_autostart => ( $auto_
pt} .= <<"EOF";
<script type="text/javascript" src="$self->{p}->{staticPrefix}/common/js/webauthn-json.browser-global.min.js?v=$cacheTag"></script>
<script type="text/javascript" src="$self->{p}->{sta
t refresh_token in response
my $tmp = JSON::from_json( $res->[2]->[0] );
$tmp->{refresh_token} = $refreshToken->id;
$res->[2]->[0] = JSON::to_json($tmp);
$req->response($res);
re