[freeside-commits] branch master updated. 16cfeae489ff1cf4b4fdd5f1ca34d2c4d313174a

Ivan Kohler ivan at freeside.biz
Wed Sep 7 17:31:32 PDT 2022


The branch, master has been updated
       via  16cfeae489ff1cf4b4fdd5f1ca34d2c4d313174a (commit)
      from  26ddb940ad27ce8ac5e87084eeed857a390987bc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 16cfeae489ff1cf4b4fdd5f1ca34d2c4d313174a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Sep 7 17:31:31 2022 -0700

    google authenticator support, RT#86743

diff --git a/FS/FS/Auth/internal.pm b/FS/FS/Auth/internal.pm
index dfc5f301d..92dff0318 100644
--- a/FS/FS/Auth/internal.pm
+++ b/FS/FS/Auth/internal.pm
@@ -7,7 +7,7 @@ use FS::Record qw( qsearchs );
 use FS::access_user;
 
 sub authenticate {
-  my($self, $username, $check_password ) = @_;
+  my($self, $username, $check_password, $totp_code ) = @_;
 
   my $access_user =
     ref($username) ? $username
@@ -17,6 +17,7 @@ sub authenticate {
                              )
     or return 0;
 
+  my $pw_check;
   if ( $access_user->_password_encoding eq 'bcrypt' ) {
 
     my( $cost, $salt, $hash ) = split(',', $access_user->_password);
@@ -29,17 +30,21 @@ sub authenticate {
                                            )
                               );
 
-    $hash eq $check_hash;
+    $pw_check = $hash eq $check_hash;
 
-  } else { 
+  } else {
 
     return 0 if $access_user->_password eq 'notyet'
              || $access_user->_password eq '';
 
-    $access_user->_password eq $check_password;
+    $pw_check = $access_user->_password eq $check_password;
 
   }
 
+  return $pw_check if ! $pw_check || ! length($access_user->totp_secret32);
+
+  #2fa
+  $access_user->google_auth->verify( $totp_code, 1 );
 }
 
 sub autocreate { 0; }

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Auth/internal.pm | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)




More information about the freeside-commits mailing list