[freeside-commits] branch 21563 updated. d139a46390d127753877e8e55766e864df788d0b

Ivan ivan at 420.am
Wed May 8 02:11:55 PDT 2013


The branch, 21563 has been updated
       via  d139a46390d127753877e8e55766e864df788d0b (commit)
       via  199450cf528a5ac6b4fe739c38f9adf99a913712 (commit)
       via  92a3df0360d3df6b6ace99fee3d4cc443e6154d0 (commit)
      from  9d35792778885932c09102bd011b518eb47c5131 (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 d139a46390d127753877e8e55766e864df788d0b
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed May 8 02:11:01 2013 -0700

    fix CCH update adding a TAXCAT, RT#21687

diff --git a/FS/FS/tax_class.pm b/FS/FS/tax_class.pm
index bfec2c0..eeb8993 100644
--- a/FS/FS/tax_class.pm
+++ b/FS/FS/tax_class.pm
@@ -259,13 +259,15 @@ sub batch_import {
                                  'description' => $type->[1].':'.$cat->[1],
                              } );
           my $error = $tax_class->insert;
-          return $error if $error;
+          return "can't insert tax_class for old TAXTYPE $type and new TAXCAT $cat: $error" if $error;
           $imported++;
         }
       }
 
+      my %cats = map { $_=>1 } ( @old_cats, @{$data->{'taxcat'}} );
+
       foreach my $type (@{$data->{'taxtype'}}) {
-        foreach my $cat (@old_cats, @{$data->{'taxcat'}}) {
+        foreach my $cat (keys %cats) {
 
           if ( $job ) {  # progress bar
             if ( time - $min_sec > $last ) {
@@ -283,7 +285,7 @@ sub batch_import {
                                  'description' => $type->[1].':'.$cat->[1],
                              } );
           my $error = $tax_class->insert;
-          return $error if $error;
+          return "can't insert tax_class for new TAXTYPE $type and TAXCAT $cat: $error" if $error;
           $imported++;
         }
       }
@@ -363,7 +365,7 @@ sub batch_import {
   my $error = &{$endhook}();
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
-    return "can't insert tax_class for $line: $error";
+    return "can't run end hook: $error";
   }
 
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;

commit 199450cf528a5ac6b4fe739c38f9adf99a913712
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue May 7 23:55:36 2013 -0700

    NG auth: internal db auth, RT#21563

diff --git a/FS/FS/Auth/internal.pm b/FS/FS/Auth/internal.pm
index 86fddd2..5d9170e 100644
--- a/FS/FS/Auth/internal.pm
+++ b/FS/FS/Auth/internal.pm
@@ -2,14 +2,44 @@ package FS::Auth::internal;
 #use base qw( FS::Auth );
 
 use strict;
+use Crypt::Eksblowfish::Bcrypt qw(bcrypt_hash);
+use FS::Record qw( qsearchs );
+use FS::access_user;
 
 sub authenticate {
-  my( $username, $check_password ) = @_;
+  my($self, $username, $check_password ) = @_;
 
+  my $access_user = qsearchs('access_user', { 'username' => $username,
+                                              'disabled' => '',
+                                            }
+                            )
+    or return 0;
 
-}
+  if ( $access_user->_password_encoding eq 'bcrypt' ) {
+
+    my( $cost, $salt, $hash ) = split(',', $access_user->_password);
+
+    my $check_hash = bcrypt_hash( { key_nul => 1,
+                                    cost    => $cost,
+                                    salt    => $salt,
+                                  },
+                                  $check_password
+                                );
+
+    $hash eq $check_hash;
+
+  } else { 
+
+    return 0 if $access_user->_password eq 'notyet'
+             || $access_user->_password eq '';
+
+    $access_user->_password eq $check_password;
+
+  }
 
-sub change_password {
 }
 
+#sub change_password {
+#}
+
 1;

commit 92a3df0360d3df6b6ace99fee3d4cc443e6154d0
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue May 7 23:55:11 2013 -0700

    NG auth: internal db auth, RT#21563

diff --git a/FS/FS/Auth.pm b/FS/FS/Auth.pm
new file mode 100644
index 0000000..543978e
--- /dev/null
+++ b/FS/FS/Auth.pm
@@ -0,0 +1,25 @@
+package FS::Auth;
+
+use strict;
+use FS::Conf;
+
+sub authenticate {
+  my $class = shift;
+
+  $class->auth_class->authenticate(@_);
+}
+
+sub auth_class {
+  #my($class) = @_;
+
+  my $conf = new FS::Conf;
+  my $module = lc($conf->config('authentication_module')) || 'internal';
+
+  my $auth_class = 'FS::Auth::'.$module;
+  eval "use $auth_class;";
+  die $@ if $@;
+
+  $auth_class;
+}
+
+1;
diff --git a/FS/FS/AuthCookieHandler.pm b/FS/FS/AuthCookieHandler.pm
index a8ee370..cd89f55 100644
--- a/FS/FS/AuthCookieHandler.pm
+++ b/FS/FS/AuthCookieHandler.pm
@@ -4,34 +4,29 @@ use base qw( Apache2::AuthCookie );
 use strict;
 use FS::UID qw( adminsuidsetup preuser_setup );
 use FS::CurrentUser;
-
-my $module = 'legacy'; #XXX i am set in a conf somehow?  or a config file
+use FS::Auth;
 
 sub authen_cred {
   my( $self, $r, $username, $password ) = @_;
 
+  preuser_setup();
+
   unless ( _is_valid_user($username, $password) ) {
     warn "failed auth $username from ". $r->connection->remote_ip. "\n";
     return undef;
   }
 
   warn "authenticated $username from ". $r->connection->remote_ip. "\n";
-  adminsuidsetup($username);
 
-  FS::CurrentUser->new_session;
+  FS::CurrentUser->load_user($username);
 
+  FS::CurrentUser->new_session;
 }
 
 sub _is_valid_user {
   my( $username, $password ) = @_;
-  my $class = 'FS::Auth::'.$module;
-
-  #earlier?
-  eval "use $class;";
-  die $@ if $@;
-
-  $class->authenticate($username, $password);
 
+  FS::Auth->authenticate($username, $password);
 }
 
 sub authen_ses_key {
@@ -47,7 +42,6 @@ sub authen_ses_key {
   }
 
   $curuser->username;
-
 }
 
 1;
diff --git a/FS/FS/Mason/Request.pm b/FS/FS/Mason/Request.pm
index 1e2555a..5d6fc4c 100644
--- a/FS/FS/Mason/Request.pm
+++ b/FS/FS/Mason/Request.pm
@@ -93,7 +93,7 @@ sub freeside_setup {
         $cgi = new CGI;
         setcgi($cgi);
 
-        #cgisuidsetup is gone, adminsuidsetup is now done in AuthCookieHandler
+        #cgisuidsetup is gone, equivalent is now done in AuthCookieHandler
 
         $fsurl = rooturl();
         $p = popurl(2);
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 923f1fd..899b67b 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -3584,13 +3584,14 @@ sub tables_hashref {
 
     'access_user' => {
       'columns' => [
-        'usernum',   'serial',  '',      '', '', '',
-        'username',  'varchar', '', $char_d, '', '',
-        '_password', 'varchar', '', $char_d, '', '',
-        'last',      'varchar', '', $char_d, '', '', 
-        'first',     'varchar', '', $char_d, '', '', 
-        'user_custnum',  'int', 'NULL',  '', '', '',
-        'disabled',     'char', 'NULL',   1, '', '', 
+        'usernum',             'serial',     '',      '', '', '',
+        'username',           'varchar',     '', $char_d, '', '',
+        '_password',          'varchar',     '', $char_d, '', '',
+        '_password_encoding', 'varchar', 'NULL', $char_d, '', '',
+        'last',               'varchar',     '', $char_d, '', '', 
+        'first',              'varchar',     '', $char_d, '', '', 
+        'user_custnum',           'int', 'NULL',      '', '', '',
+        'disabled',              'char', 'NULL',       1, '', '', 
       ],
       'primary_key' => 'usernum',
       'unique' => [ [ 'username' ] ],
diff --git a/eg/access_user-external_auth.pm b/eg/Auth-my_external_auth.pm
similarity index 56%
rename from eg/access_user-external_auth.pm
rename to eg/Auth-my_external_auth.pm
index bc6e23a..38f9d5b 100644
--- a/eg/access_user-external_auth.pm
+++ b/eg/Auth-my_external_auth.pm
@@ -1,11 +1,10 @@
-package FS::access_user::external_auth;
-use base qw( FS::access_user::external ); #inherit from ::external for
-                                          # autocreation
+package FS::Auth::my_external_auth;
+use base qw( FS::Auth::external ); #need to inherit from ::external
 
 use strict;
 
 sub authenticate {
-  my( $username, $check_password ) = @_;
+  my($self, $username, $check_password ) = @_;
 
   #magic happens here
 

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

Summary of changes:
 FS/FS/Auth.pm                                      |   25 ++++++++++++++
 FS/FS/Auth/internal.pm                             |   36 ++++++++++++++++++--
 FS/FS/AuthCookieHandler.pm                         |   18 +++------
 FS/FS/Mason/Request.pm                             |    2 +-
 FS/FS/Schema.pm                                    |   15 ++++----
 FS/FS/tax_class.pm                                 |   10 +++--
 ...r-external_auth.pm => Auth-my_external_auth.pm} |    7 ++--
 7 files changed, 82 insertions(+), 31 deletions(-)
 create mode 100644 FS/FS/Auth.pm
 rename eg/{access_user-external_auth.pm => Auth-my_external_auth.pm} (56%)




More information about the freeside-commits mailing list