From 5512d38f8134aeadbffc702da91c2ace11788435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20OUDOT?= Date: Wed, 18 Sep 2019 18:09:18 +0200 Subject: [PATCH] Improve log on 2F unregistration (#1702) --- .../lib/Lemonldap/NG/Portal/2F/Register/TOTP.pm | 10 ++++++++-- .../lib/Lemonldap/NG/Portal/2F/Register/U2F.pm | 10 ++++++++-- .../lib/Lemonldap/NG/Portal/2F/Register/Yubikey.pm | 10 ++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/TOTP.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/TOTP.pm index 79709b8be..63be15344 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/TOTP.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/TOTP.pm @@ -301,12 +301,18 @@ sub run { } # Delete TOTP 2F device + my $TOTPName; + foreach (@$_2fDevices) { + $TOTPName = $_->{name} if $_->{epoch} eq $epoch; + } @$_2fDevices = grep { $_->{epoch} ne $epoch } @$_2fDevices; $self->logger->debug( - "Delete 2F Device : { type => 'TOTP', epoch => $epoch }"); +"Delete 2F Device : { type => 'TOTP', epoch => $epoch, name => $TOTPName }" + ); $self->p->updatePersistentSession( $req, { _2fDevices => to_json($_2fDevices) } ); - $self->userLogger->notice('TOTP deletion succeed'); + $self->userLogger->notice( + "TOTP $TOTPName unregistration succeeds for $user"); return [ 200, [ 'Content-Type' => 'application/json', 'Content-Length' => 12, ], diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/U2F.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/U2F.pm index 74f3bb570..563885f49 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/U2F.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/U2F.pm @@ -288,12 +288,18 @@ sub run { } # Delete U2F device + my $keyName; + foreach (@$_2fDevices) { + $keyName = $_->{name} if $_->{epoch} eq $epoch; + } @$_2fDevices = grep { $_->{epoch} ne $epoch } @$_2fDevices; $self->logger->debug( - "Delete 2F Device : { type => 'U2F', epoch => $epoch }"); +"Delete 2F Device : { type => 'U2F', epoch => $epoch, name => $keyName }" + ); $self->p->updatePersistentSession( $req, { _2fDevices => to_json($_2fDevices) } ); - $self->userLogger->notice('U2F key unregistration succeed'); + $self->userLogger->notice( + "U2F key $keyName unregistration succeeds for $user"); return [ 200, [ 'Content-Type' => 'application/json', 'Content-Length' => 12, ], diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/Yubikey.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/Yubikey.pm index 4f361ba6e..6e7d0755c 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/Yubikey.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Register/Yubikey.pm @@ -181,12 +181,18 @@ sub run { } # Delete Yubikey device + my $UBKName; + foreach (@$_2fDevices) { + $UBKName = $_->{name} if $_->{epoch} eq $epoch; + } @$_2fDevices = grep { $_->{epoch} ne $epoch } @$_2fDevices; $self->logger->debug( - "Delete 2F Device : { type => 'UBK', epoch => $epoch }"); +"Delete 2F Device : { type => 'UBK', epoch => $epoch, name => $UBKName }" + ); $self->p->updatePersistentSession( $req, { _2fDevices => to_json($_2fDevices) } ); - $self->userLogger->notice('Yubikey deletion succeed'); + $self->userLogger->notice( + "Yubikey $UBKName unregistration succeeds for $user"); return [ 200, [ 'Content-Type' => 'application/json', 'Content-Length' => 12, ],