Refactor Webauthn

This commit is contained in:
Maxime Besson 2022-03-30 00:06:43 +02:00
parent 21745359a2
commit 0f6753d188
2 changed files with 5 additions and 8 deletions

View File

@ -82,11 +82,9 @@ sub _generate_user_handle {
sub _registrationchallenge {
my ( $self, $req, $user ) = @_;
my @_2fDevices = $self->find2fByType( $req, $req->userData );
# Check if user can register one more 2F device
my $size = @_2fDevices;
my $maxSize = $self->conf->{max2FDevices};
my @alldevices = $self->find2fDevicesByType( $req, $req->userData );
my $size = @alldevices;
my $maxSize = $self->conf->{max2FDevices};
$self->logger->debug("Registered 2F Device(s): $size / $maxSize");
if ( $size >= $maxSize ) {
$self->userLogger->warn("Max number of 2F devices is reached");
@ -180,7 +178,7 @@ sub _registration {
if (
$self->find2fDevicesByKey(
$req, $req->userData, $self->type,
$req, $req->userData, $self->type,
"_credentialId", $credential_id
)
)

View File

@ -36,8 +36,7 @@ sub init {
if ( $self->conf->{webauthn2fSelfRegistration}
and $self->conf->{webauthn2fActivation} eq '1' )
{
$self->conf->{webauthn2fActivation} =
'$_2fDevices && $_2fDevices =~ /"type"\s*:\s*"WebAuthn"/s';
$self->conf->{webauthn2fActivation} = 'has2f("WebAuthn")';
}
return 0
unless ( $self->Lemonldap::NG::Portal::Main::SecondFactor::init() );