Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / FS / FS / Password_Mixin.pm
index af4c5e2..9d5421b 100644 (file)
@@ -4,7 +4,7 @@ use FS::Record qw(qsearch);
 use FS::Conf;
 use FS::password_history;
 use Authen::Passphrase;
-# use Authen::Passphrase::BlowfishCrypt; # ha ha, no.
+use Authen::Passphrase::BlowfishCrypt;
 # https://rt.cpan.org/Ticket/Display.html?id=72743
 
 our $DEBUG = 1;
@@ -12,7 +12,7 @@ our $conf;
 FS::UID->install_callback( sub {
     $conf = FS::Conf->new;
     # this is safe
-    eval "use Authen::Passphrase::BlowfishCrypt;";
+    #eval "use Authen::Passphrase::BlowfishCrypt;";
 });
 
 our $me = '[' . __PACKAGE__ . ']';
@@ -105,7 +105,16 @@ sub insert_password_history {
   my $password = $self->_password;
   my $auth;
 
-  if ( $encoding eq 'bcrypt' or $encoding eq 'crypt' ) {
+  if ( $encoding eq 'bcrypt' ) {
+    # our format, used for contact and access_user passwords
+    my ($cost, $salt, $hash) = split(',', $password);
+    $auth = Authen::Passphrase::BlowfishCrypt->new(
+      cost        => $cost,
+      salt_base64 => $salt,
+      hash_base64 => $hash,
+    );
+
+  } elsif ( $encoding eq 'crypt' ) {
 
     # it's smart enough to figure this out
     $auth = Authen::Passphrase->from_crypt($password);