Merge branch 'marekwojtowicz-v2.0-patch-80762' into 'v2.0'

Support for multiple yubikeys.

See merge request lemonldap-ng/lemonldap-ng!201
merge-requests/181/merge
Christophe Maudoux 4 years ago
commit 79eaa9cbcf
  1. 14
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Yubikey.pm

@ -86,7 +86,7 @@ sub init {
sub _findYubikey {
my ( $self, $req, $sessionInfo ) = @_;
my ( $yubikey, $_2fDevices );
my ( $yubikey, $_2fDevices, $code );
# First, lookup from session attribute
if ( $self->conf->{yubikey2fFromSessionAttribute} ) {
@ -109,8 +109,14 @@ sub _findYubikey {
$self->logger->debug("2F Device(s) found");
$self->logger->debug("Reading Yubikey ...");
$yubikey = $_->{_yubikey}
foreach grep { $_->{type} eq 'UBK' } @$_2fDevices;
if ( $code = $req->param('code') ) {
$yubikey = $_->{_yubikey}
foreach grep { ($_->{type} eq 'UBK') and ( $_->{_yubikey} eq
substr( $code, 0, $self->conf->{yubikey2fPublicIDSize} ) ) } @$_2fDevices;
} else {
$yubikey = $_->{_yubikey}
foreach grep { $_->{type} eq 'UBK' } @$_2fDevices;
}
}
return $yubikey;
@ -171,7 +177,7 @@ sub verify {
if (
index( $yubikey,
substr( $code, 0, $self->conf->{yubikey2fPublicIDSize} ) ) == -1
)
)
{
$self->userLogger->warn('Yubikey not registered');
return PE_BADOTP;

Loading…
Cancel
Save