From b1dc72452a975ab371c05f072bf4cd8f4d56ba01 Mon Sep 17 00:00:00 2001 From: Christophe Maudoux Date: Tue, 17 Apr 2018 20:05:45 +0200 Subject: [PATCH] Multi U2F - Fix errors ;-) - IT WORKS !!! --- .../lib/Lemonldap/NG/Portal/2F/U2F.pm | 16 +++++++--------- lemonldap-ng-portal/site/coffee/u2fcheck.coffee | 4 ++-- .../site/htdocs/static/common/js/u2fcheck.js | 4 ++-- .../site/htdocs/static/common/js/u2fcheck.min.js | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/U2F.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/U2F.pm index b262a78ff..259599846 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/U2F.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/U2F.pm @@ -58,7 +58,7 @@ sub run { # Get a challenge (from first key) my $data = eval { - JSON::from_json( + from_json( $req->datas->{crypter}->[0]->authenticationChallenge ); }; if ($@) { @@ -78,7 +78,7 @@ sub run { __ch => $data->{challenge} ); # Serialize datas - $data = JSON::to_json( + $data = to_json( { challenge => $data->{challenge}, appId => $data->{appId}, @@ -214,23 +214,22 @@ sub loadUser { $self->logger->debug("2F Device(s) found"); foreach (@$_2fDevices) { - $self->logger->debug("Reading U2F keys if exists ..."); + $self->logger->debug("Looking for registered U2F key(s) ..."); if ( $_->{type} eq 'U2F' ) { unless ( $_->{_userKey} and $_->{_userKey} ) { $self->logger->error( -"Missing required U2F attribute in storage ($session->{_2fDevices})" +"Missing required U2F attributes in storage ($session->{_2fDevices})" ); next; } - $self->logger->debug( "_userKey = " . $_->{_userKey} ); - $self->logger->debug( "_keyHandle = " . $_->{_keyHandle} ); + $self->logger->debug( "Found U2F key -> _userKey = " . $_->{_userKey} . "/ _keyHandle = " . $_->{_keyHandle} ); $_->{_userKey} = $self->decode_base64url( $_->{_userKey} ); push @u2fs, $_; } } } - #### TODO : MANAGE MULTI U2F KEYS + #### MANAGE MULTI U2F KEYS my @crypters; if (@u2fs) { $self->logger->debug("kh & uk -> OK"); @@ -250,12 +249,11 @@ sub loadUser { unless (@crypters) { return -1; } - $req->datas->{crypter} = \@crypters; return 1; } else { - $self->userLogger->info("U2F: user not registered"); + $self->userLogger->info("U2F : user not registered"); return 0; } } diff --git a/lemonldap-ng-portal/site/coffee/u2fcheck.coffee b/lemonldap-ng-portal/site/coffee/u2fcheck.coffee index 87a14868c..66f45005c 100644 --- a/lemonldap-ng-portal/site/coffee/u2fcheck.coffee +++ b/lemonldap-ng-portal/site/coffee/u2fcheck.coffee @@ -3,8 +3,8 @@ LemonLDAP::NG U2F verify script ### check = -> - u2f.sign window.datas.appId, window.datas.challenge, windows.datas.registeredKeys, (data) -> - $('#verify-data').val data + u2f.sign window.datas.appId, window.datas.challenge, window.datas.registeredKeys, (data) -> + $('#verify-data').val JSON.stringify data $('#verify-challenge').val window.datas.challenge $('#verify-form').submit() diff --git a/lemonldap-ng-portal/site/htdocs/static/common/js/u2fcheck.js b/lemonldap-ng-portal/site/htdocs/static/common/js/u2fcheck.js index 5db386677..9e5bfa889 100644 --- a/lemonldap-ng-portal/site/htdocs/static/common/js/u2fcheck.js +++ b/lemonldap-ng-portal/site/htdocs/static/common/js/u2fcheck.js @@ -8,8 +8,8 @@ LemonLDAP::NG U2F verify script var check; check = function() { - return u2f.sign(window.datas.appId, window.datas.challenge, windows.datas.registeredKeys, function(data) { - $('#verify-data').val(data); + return u2f.sign(window.datas.appId, window.datas.challenge, window.datas.registeredKeys, function(data) { + $('#verify-data').val(JSON.stringify(data)); $('#verify-challenge').val(window.datas.challenge); return $('#verify-form').submit(); }); diff --git a/lemonldap-ng-portal/site/htdocs/static/common/js/u2fcheck.min.js b/lemonldap-ng-portal/site/htdocs/static/common/js/u2fcheck.min.js index 3ad694a8c..978f2acd4 100644 --- a/lemonldap-ng-portal/site/htdocs/static/common/js/u2fcheck.min.js +++ b/lemonldap-ng-portal/site/htdocs/static/common/js/u2fcheck.min.js @@ -1 +1 @@ -(function(){var a;a=function(){return u2f.sign(window.datas.appId,window.datas.challenge,windows.datas.registeredKeys,function(b){$("#verify-data").val(b);$("#verify-challenge").val(window.datas.challenge);return $("#verify-form").submit()})};$(document).ready(function(){return setTimeout(a,1000)})}).call(this); \ No newline at end of file +(function(){var a;a=function(){return u2f.sign(window.datas.appId,window.datas.challenge,window.datas.registeredKeys,function(b){$("#verify-data").val(JSON.stringify(b));$("#verify-challenge").val(window.datas.challenge);return $("#verify-form").submit()})};$(document).ready(function(){return setTimeout(a,1000)})}).call(this); \ No newline at end of file