Improve code & typo

merge-requests/133/head
Christophe Maudoux 5 years ago
parent 6c317b9106
commit 385a1c1f38
  1. 38
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Tree.pm
  2. 2
      lemonldap-ng-manager/site/htdocs/static/languages/fr.json
  3. 2
      lemonldap-ng-manager/site/htdocs/static/struct.json
  4. 19
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/TOTP.pm
  5. 12
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/U2F.pm
  6. 14
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/Yubikey.pm
  7. 17
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/U2F.pm
  8. 12
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/UTOTP.pm
  9. 8
      lemonldap-ng-portal/site/coffee/totpregistration.coffee
  10. 2
      lemonldap-ng-portal/site/coffee/u2fregistration.coffee
  11. 4
      lemonldap-ng-portal/site/htdocs/static/languages/fr.json

@ -807,6 +807,25 @@ sub tree {
'u2fLogo', 'u2fLogo',
] ]
}, },
{
title => 'yubikey2f',
help => 'yubikey2f.html',
form => 'simpleInputContainer',
nodes => [
'yubikey2fActivation',
'yubikey2fSelfRegistration',
'yubikey2fClientID',
'yubikey2fSecretKey',
'yubikey2fNonce',
'yubikey2fUrl',
'yubikey2fPublicIDSize',
'yubikey2fUserCanRemoveKey',
'yubikey2fTTL',
'yubikey2fAuthnLevel',
'yubikey2fLabel',
'yubikey2fLogo',
],
},
{ {
title => 'mail2f', title => 'mail2f',
help => 'mail2f.html', help => 'mail2f.html',
@ -854,25 +873,6 @@ sub tree {
'rest2fLabel', 'rest2fLogo', 'rest2fLabel', 'rest2fLogo',
] ]
}, },
{
title => 'yubikey2f',
help => 'yubikey2f.html',
form => 'simpleInputContainer',
nodes => [
'yubikey2fActivation',
'yubikey2fSelfRegistration',
'yubikey2fClientID',
'yubikey2fSecretKey',
'yubikey2fNonce',
'yubikey2fUrl',
'yubikey2fPublicIDSize',
'yubikey2fUserCanRemoveKey',
'yubikey2fTTL',
'yubikey2fAuthnLevel',
'yubikey2fLabel',
'yubikey2fLogo',
],
},
'sfExtra', 'sfExtra',
{ {
title => 'sfRemovedNotification', title => 'sfRemovedNotification',

@ -817,7 +817,7 @@
"sessionStorage":"Stockage des sessions", "sessionStorage":"Stockage des sessions",
"sessionTitle":"Contenu de la session", "sessionTitle":"Contenu de la session",
"sfaTitle":"Seconds Facteurs d'Authentification", "sfaTitle":"Seconds Facteurs d'Authentification",
"sfExtra":"Seconds Facteurs additionnels", "sfExtra":"Seconds facteurs additionnels",
"sfRequired":"Exiger 2FA", "sfRequired":"Exiger 2FA",
"sfRemovedNotification":"Afficher un message si un SF expiré a été supprimé", "sfRemovedNotification":"Afficher un message si un SF expiré a été supprimé",
"sfRemovedMsgRule":"Activation", "sfRemovedMsgRule":"Activation",

File diff suppressed because one or more lines are too long

@ -5,7 +5,7 @@ use strict;
use Mouse; use Mouse;
use JSON qw(from_json to_json); use JSON qw(from_json to_json);
our $VERSION = '2.0.6'; our $VERSION = '2.0.8';
extends 'Lemonldap::NG::Portal::Main::Plugin', 'Lemonldap::NG::Common::TOTP'; extends 'Lemonldap::NG::Portal::Main::Plugin', 'Lemonldap::NG::Common::TOTP';
@ -133,10 +133,8 @@ sub run {
} }
# Loading TOTP secret # Loading TOTP secret
foreach (@totp2f) { $self->logger->debug("Reading TOTP secret if exists ...");
$self->logger->debug("Reading TOTP secret if exists ..."); $secret = $_->{_secret} foreach (@totp2f);
$secret = $_->{_secret};
}
if ( $token->{_totp2fSecret} eq $secret ) { if ( $token->{_totp2fSecret} eq $secret ) {
return $self->p->sendError( $req, 'totpExistingKey', 200 ); return $self->p->sendError( $req, 'totpExistingKey', 200 );
@ -217,10 +215,8 @@ sub run {
} }
# Loading TOTP secret # Loading TOTP secret
foreach (@totp2f) { $self->logger->debug("Reading TOTP secret if exists ...");
$self->logger->debug("Reading TOTP secret if exists ..."); $secret = $_->{_secret} foreach (@totp2f);
$secret = $_->{_secret};
}
if ( ( $req->param('newkey') and $self->conf->{totp2fUserCanChangeKey} ) if ( ( $req->param('newkey') and $self->conf->{totp2fUserCanChangeKey} )
or not $secret ) or not $secret )
@ -274,9 +270,8 @@ sub run {
elsif ( $action eq 'delete' ) { elsif ( $action eq 'delete' ) {
# Check if unregistration is allowed # Check if unregistration is allowed
unless ( $self->conf->{totp2fUserCanRemoveKey} ) { return $self->p->sendError( $req, 'notAuthorized', 400 )
return $self->p->sendError( $req, 'notAuthorized', 400 ); unless $self->conf->{totp2fUserCanRemoveKey};
}
my $epoch = $req->param('epoch') my $epoch = $req->param('epoch')
or return $self->p->sendError( $req, '"epoch" parameter is missing', or return $self->p->sendError( $req, '"epoch" parameter is missing',

@ -5,7 +5,7 @@ use strict;
use Mouse; use Mouse;
use JSON qw(from_json to_json); use JSON qw(from_json to_json);
our $VERSION = '2.0.6'; our $VERSION = '2.0.8';
extends 'Lemonldap::NG::Portal::Main::Plugin', extends 'Lemonldap::NG::Portal::Main::Plugin',
'Lemonldap::NG::Portal::Lib::U2F'; 'Lemonldap::NG::Portal::Lib::U2F';
@ -261,9 +261,8 @@ sub run {
elsif ( $action eq 'delete' ) { elsif ( $action eq 'delete' ) {
# Check if unregistration is allowed # Check if unregistration is allowed
unless ( $self->conf->{u2fUserCanRemoveKey} ) { return $self->p->sendError( $req, 'notAuthorized', 200 )
return $self->p->sendError( $req, 'notAuthorized', 200 ); unless $self->conf->{u2fUserCanRemoveKey};
}
my $epoch = $req->param('epoch') my $epoch = $req->param('epoch')
or return $self->p->sendError( $req, '"epoch" parameter is missing', or return $self->p->sendError( $req, '"epoch" parameter is missing',
@ -371,9 +370,8 @@ sub loadUser {
'U2F error: ' . Crypt::U2F::Server::u2fclib_getError() ); 'U2F error: ' . Crypt::U2F::Server::u2fclib_getError() );
} }
} }
unless (@crypters) { return -1 unless @crypters;
return -1;
}
$req->data->{crypter} = \@crypters; $req->data->{crypter} = \@crypters;
return 1; return 1;
} }

@ -9,7 +9,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
PE_ERROR PE_ERROR
); );
our $VERSION = '2.0.6'; our $VERSION = '2.0.8';
extends 'Lemonldap::NG::Portal::Main::Plugin'; extends 'Lemonldap::NG::Portal::Main::Plugin';
@ -32,10 +32,9 @@ sub init {
sub run { sub run {
my ( $self, $req, $action ) = @_; my ( $self, $req, $action ) = @_;
my $user = $req->userData->{ $self->conf->{whatToTrace} }; my $user = $req->userData->{ $self->conf->{whatToTrace} };
unless ($user) { return $self->p->sendError( $req,
return $self->p->sendError( $req, 'No ' . $self->conf->{whatToTrace} . ' found in user data', 500 )
'No ' . $self->conf->{whatToTrace} . ' found in user data', 500 ); unless $user;
}
if ( $action eq 'register' ) { if ( $action eq 'register' ) {
my $otp = $req->param('otp'); my $otp = $req->param('otp');
@ -154,9 +153,8 @@ sub run {
elsif ( $action eq 'delete' ) { elsif ( $action eq 'delete' ) {
# Check if unregistration is allowed # Check if unregistration is allowed
unless ( $self->conf->{yubikey2fUserCanRemoveKey} ) { return $self->p->sendError( $req, 'notAuthorized', 400 )
return $self->p->sendError( $req, 'notAuthorized', 400 ); unless $self->conf->{yubikey2fUserCanRemoveKey};
}
my $epoch = $req->param('epoch') my $epoch = $req->param('epoch')
or return $self->p->sendError( $req, '"epoch" parameter is missing', or return $self->p->sendError( $req, '"epoch" parameter is missing',

@ -16,7 +16,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
PE_U2FFAILED PE_U2FFAILED
); );
our $VERSION = '2.0.0'; our $VERSION = '2.0.8';
extends 'Lemonldap::NG::Portal::Main::SecondFactor', extends 'Lemonldap::NG::Portal::Main::SecondFactor',
'Lemonldap::NG::Portal::Lib::U2F'; 'Lemonldap::NG::Portal::Lib::U2F';
@ -43,6 +43,7 @@ sub init {
return 0 return 0
unless ( $self->Lemonldap::NG::Portal::Main::SecondFactor::init() unless ( $self->Lemonldap::NG::Portal::Main::SecondFactor::init()
and $self->Lemonldap::NG::Portal::Lib::U2F::init() ); and $self->Lemonldap::NG::Portal::Lib::U2F::init() );
1; 1;
} }
@ -71,12 +72,9 @@ sub run {
} }
# Get registered keys # Get registered keys
my @rk; my @rk =
foreach ( @{ $req->data->{crypter} } ) { map { { keyHandle => $_->{keyHandle}, version => $data->{version} } }
push @rk, @{ $req->data->{crypter} };
{ keyHandle => $_->{keyHandle}, version => $data->{version} };
}
$self->ott->updateToken( $token, __ch => $data->{challenge} ); $self->ott->updateToken( $token, __ch => $data->{challenge} );
@ -247,9 +245,8 @@ sub loadUser {
'U2F error: ' . Crypt::U2F::Server::u2fclib_getError() ); 'U2F error: ' . Crypt::U2F::Server::u2fclib_getError() );
} }
} }
unless (@crypters) { return -1 unless (@crypters);
return -1;
}
$req->data->{crypter} = \@crypters; $req->data->{crypter} = \@crypters;
return 1; return 1;
} }

@ -6,7 +6,7 @@ use JSON qw(from_json to_json);
use Lemonldap::NG::Portal::Main::Constants qw( use Lemonldap::NG::Portal::Main::Constants qw(
); );
our $VERSION = '2.0.0'; our $VERSION = '2.0.8';
extends 'Lemonldap::NG::Portal::Main::SecondFactor'; extends 'Lemonldap::NG::Portal::Main::SecondFactor';
@ -86,12 +86,10 @@ sub run {
} }
# Get registered keys # Get registered keys
my @rk; my @rk =
foreach ( @{ $req->data->{crypter} } ) { map {
push @rk, { keyHandle => $_->{keyHandle}, version => $data->{version} }
{ keyHandle => $_->{keyHandle}, version => $data->{version} }; } @{ $req->data->{crypter} };
}
$self->ott->updateToken( $token, __ch => $data->{challenge} ); $self->ott->updateToken( $token, __ch => $data->{challenge} );

@ -13,7 +13,7 @@ displayError = (j, status, err) ->
console.log 'Error', err console.log 'Error', err
res = JSON.parse j.responseText res = JSON.parse j.responseText
if res and res.error if res and res.error
res = res.error.replace /.* /, '' res = res.error.replace(/.* /, '')
console.log 'Returned error', res console.log 'Returned error', res
setMsg res, 'warning' setMsg res, 'warning'
@ -83,7 +83,5 @@ verify = ->
$(document).ready -> $(document).ready ->
getKey(0) getKey(0)
$('#changekey').on 'click', () -> $('#changekey').on 'click', () -> getKey(1)
getKey(1) $('#verify').on 'click', () -> verify()
$('#verify').on 'click', () ->
verify()

@ -13,7 +13,7 @@ displayError = (j, status, err) ->
console.log 'Error', err console.log 'Error', err
res = JSON.parse j.responseText res = JSON.parse j.responseText
if res and res.error if res and res.error
res = res.error.replace /.* /, '' res = res.error.replace(/.* /, '')
console.log 'Returned error', res console.log 'Returned error', res
setMsg res, 'warning' setMsg res, 'warning'

@ -33,7 +33,7 @@
"PE41":"Ouverture de session interdite", "PE41":"Ouverture de session interdite",
"PE42":"Confirmation demandée", "PE42":"Confirmation demandée",
"PE43":"L'adresse mail est obligatoire", "PE43":"L'adresse mail est obligatoire",
"PE44":"La clé de confirmation est invalide ou trop ancienne", "PE44":"La clef de confirmation est invalide ou trop ancienne",
"PE45":"L'envoi du mail a échoué", "PE45":"L'envoi du mail a échoué",
"PE46":"Un mail vous a été envoyé", "PE46":"Un mail vous a été envoyé",
"PE47":"Vous avez été déconnecté", "PE47":"Vous avez été déconnecté",
@ -271,7 +271,7 @@
"touchU2fDeviceOrEnterTotp": "Posez votre doigt sur le périphérique U2F ou entrez le code TOTP", "touchU2fDeviceOrEnterTotp": "Posez votre doigt sur le périphérique U2F ou entrez le code TOTP",
"type":"Type", "type":"Type",
"UA":"Agent utlisateur", "UA":"Agent utlisateur",
"u2f":"Clé U2F", "u2f":"Clef U2F",
"u2fFailed": "La vérification U2F a échoué. Réessayez ou contactez votre administrateur", "u2fFailed": "La vérification U2F a échoué. Réessayez ou contactez votre administrateur",
"u2fPermission": "Il est possible qu'on vous demande d'autoriser le site à accéder à votre clef. Après votre accord, la clef clignotera.", "u2fPermission": "Il est possible qu'on vous demande d'autoriser le site à accéder à votre clef. Après votre accord, la clef clignotera.",
"u2fWelcome": "Gestion du périphérique U2F", "u2fWelcome": "Gestion du périphérique U2F",

Loading…
Cancel
Save