Commit 7802cbcc authored by Christophe Maudoux's avatar Christophe Maudoux 🐛

Optionaly let Ext2F module handle code generation (#1632)

parent 90ddec7c
...@@ -33,9 +33,11 @@ sub init { ...@@ -33,9 +33,11 @@ sub init {
if ( $self->conf->{ext2fLogo} ); if ( $self->conf->{ext2fLogo} );
return $self->SUPER::init(); return $self->SUPER::init();
} }
if ( $self->conf->{ext2fCodeActivation} if ( $self->conf->{ext2fCodeActivation} ) {
and $self->conf->{ext2FSendCommand} ) unless ( $self->conf->{ext2FSendCommand} ) {
{ $self->error("Missing 'ext2FSendCommand' parameter, aborting");
return 0;
}
$self->random( String::Random->new ); $self->random( String::Random->new );
$self->logo( $self->conf->{ext2fLogo} ) $self->logo( $self->conf->{ext2fLogo} )
if ( $self->conf->{ext2fLogo} ); if ( $self->conf->{ext2fLogo} );
...@@ -52,10 +54,11 @@ sub run { ...@@ -52,10 +54,11 @@ sub run {
my $checkLogins = $req->param('checkLogins'); my $checkLogins = $req->param('checkLogins');
$self->logger->debug("Ext2F checkLogins set") if ($checkLogins); $self->logger->debug("Ext2F checkLogins set") if ($checkLogins);
# Generate OTP to send # Generate Code to send
if ( $self->{random} ) { my $code;
my $code if ( $self->conf->{ext2fCodeActivation} ) {
= $self->random->randregex( $self->conf->{ext2fOTPActivation} ); $code
= $self->random->randregex( $self->conf->{ext2fCodeActivation} );
$self->logger->debug("Generated ext2f code : $code"); $self->logger->debug("Generated ext2f code : $code");
$self->ott->updateToken( $token, __ext2fcode => $code ); $self->ott->updateToken( $token, __ext2fcode => $code );
} }
...@@ -64,7 +67,7 @@ sub run { ...@@ -64,7 +67,7 @@ sub run {
$self->logger->debug( 'Launching "Send" external 2F command -> ' $self->logger->debug( 'Launching "Send" external 2F command -> '
. $self->conf->{ext2FSendCommand} ); . $self->conf->{ext2FSendCommand} );
if ( my $c if ( my $c
= $self->launch( $req->sessionInfo, $self->conf->{ext2FSendCommand} ) = $self->launch( $req->sessionInfo, $self->conf->{ext2FSendCommand}, $code )
) )
{ {
$self->logger->error("External send command failed (code $c)"); $self->logger->error("External send command failed (code $c)");
...@@ -92,7 +95,7 @@ sub verify { ...@@ -92,7 +95,7 @@ sub verify {
my ( $self, $req, $session ) = @_; my ( $self, $req, $session ) = @_;
my $usercode; my $usercode;
unless ( $usercode = $req->param('code') ) { unless ( $usercode = $req->param('code') ) {
$self->userLogger->error('External 2F: no code'); $self->userLogger->error('External 2F: no code found');
return PE_FORMEMPTY; return PE_FORMEMPTY;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment