Verify if max 2F devices is not reached (#1386)
This commit is contained in:
parent
ff9ef7aab3
commit
a3ba56aa12
|
@ -29,6 +29,8 @@ has ott => (
|
||||||
);
|
);
|
||||||
|
|
||||||
sub init {
|
sub init {
|
||||||
|
my ($self) = @_;
|
||||||
|
$self->conf->{max2FDevices} ||= 10;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +108,22 @@ sub run {
|
||||||
$self->logger->debug("No 2F Device found");
|
$self->logger->debug("No 2F Device found");
|
||||||
$_2FDevices = [];
|
$_2FDevices = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if user can register one more device
|
||||||
|
my $size = @$_2FDevices;
|
||||||
|
$self->logger->debug(
|
||||||
|
"Nbr 2FDevices = $size / $self->conf->{max2FDevices}");
|
||||||
|
if ( $size > $self->conf->{max2FDevices} ) {
|
||||||
|
$self->userLogger->error("Max number of 2F devices is reached !!!");
|
||||||
|
return $self->p->sendHtml(
|
||||||
|
$req, 'error',
|
||||||
|
params => {
|
||||||
|
RAW_ERROR => 'MaxNumberof2FDevicesReached',
|
||||||
|
AUTH_ERROR_TYPE => 'warning',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
push @{$_2FDevices},
|
push @{$_2FDevices},
|
||||||
{
|
{
|
||||||
type => 'TOTP',
|
type => 'TOTP',
|
||||||
|
|
|
@ -19,6 +19,7 @@ has logo => ( is => 'rw', default => 'u2f.png' );
|
||||||
|
|
||||||
sub init {
|
sub init {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
$self->conf->{max2FDevices} ||= 10;
|
||||||
return 0 unless $self->SUPER::init;
|
return 0 unless $self->SUPER::init;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +77,23 @@ sub run {
|
||||||
# Set default value
|
# Set default value
|
||||||
$_2FDevices = [];
|
$_2FDevices = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if user can register one more device
|
||||||
|
my $size = @$_2FDevices;
|
||||||
|
$self->logger->debug(
|
||||||
|
"Nbr 2FDevices = $size / $self->conf->{max2FDevices}");
|
||||||
|
if ( $size > $self->conf->{max2FDevices} ) {
|
||||||
|
$self->userLogger->error(
|
||||||
|
"Max number of 2F devices is reached !!!");
|
||||||
|
return $self->p->sendHtml(
|
||||||
|
$req, 'error',
|
||||||
|
params => {
|
||||||
|
RAW_ERROR => 'MaxNumberof2FDevicesReached',
|
||||||
|
AUTH_ERROR_TYPE => 'warning',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
my $keyName = $req->param('keyName');
|
my $keyName = $req->param('keyName');
|
||||||
my $epoch = time();
|
my $epoch = time();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ has logo => ( is => 'rw', default => 'yubikey.png' );
|
||||||
sub init {
|
sub init {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
$self->conf->{yubikey2fPublicIDSize} ||= 12;
|
$self->conf->{yubikey2fPublicIDSize} ||= 12;
|
||||||
|
$self->conf->{max2FDevices} ||= 10;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,12 +58,6 @@ sub run {
|
||||||
$_2FDevices = [];
|
$_2FDevices = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
# Select U2F Devices only
|
|
||||||
#my @listU2FKeys = map {
|
|
||||||
#( $_->{type} eq "U2F" ) ? return $_ : return ();
|
|
||||||
#} @{$_2FDevices};
|
|
||||||
#$self->logger->debug("Select U2F Devices only ...");
|
|
||||||
|
|
||||||
# Search if Yubikey has been already registered
|
# Search if Yubikey has been already registered
|
||||||
my $SameUBKFound = 0;
|
my $SameUBKFound = 0;
|
||||||
foreach (@$_2FDevices) {
|
foreach (@$_2FDevices) {
|
||||||
|
@ -85,6 +80,22 @@ sub run {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if user can register one more device
|
||||||
|
my $size = @$_2FDevices;
|
||||||
|
$self->logger->debug(
|
||||||
|
"Nbr 2FDevices = $size / $self->conf->{max2FDevices}");
|
||||||
|
if ( $size > $self->conf->{max2FDevices} ) {
|
||||||
|
$self->userLogger->error(
|
||||||
|
"Max number of 2F devices is reached !!!");
|
||||||
|
return $self->p->sendHtml(
|
||||||
|
$req, 'error',
|
||||||
|
params => {
|
||||||
|
RAW_ERROR => 'MaxNumberof2FDevicesReached',
|
||||||
|
AUTH_ERROR_TYPE => 'warning',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
push @{$_2FDevices},
|
push @{$_2FDevices},
|
||||||
{
|
{
|
||||||
type => 'UBK',
|
type => 'UBK',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user