[Catalyst-commits] r8572 - in trunk/Catalyst-Authentication-Store-DBIx-Class: . lib/Catalyst/Authentication/Store/DBIx lib/Catalyst/Authentication/Store/DBIx/Class t

jayk at dev.catalyst.perl.org jayk at dev.catalyst.perl.org
Sun Oct 26 23:27:59 GMT 2008


Author: jayk
Date: 2008-10-26 23:27:59 +0000 (Sun, 26 Oct 2008)
New Revision: 8572

Modified:
   trunk/Catalyst-Authentication-Store-DBIx-Class/Changes
   trunk/Catalyst-Authentication-Store-DBIx-Class/Makefile.PL
   trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class.pm
   trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm
   trunk/Catalyst-Authentication-Store-DBIx-Class/t/02-pod-coverage.t
   trunk/Catalyst-Authentication-Store-DBIx-Class/t/03-authtest.t
   trunk/Catalyst-Authentication-Store-DBIx-Class/t/04-authsessions.t
   trunk/Catalyst-Authentication-Store-DBIx-Class/t/05-auth-roles-relationship.t
   trunk/Catalyst-Authentication-Store-DBIx-Class/t/06-auth-roles-column.t
   trunk/Catalyst-Authentication-Store-DBIx-Class/t/07-authsessions-cached.t
Log:
Adding SimpleDB Realm to make basic configuration of DBIx::Class / Password
based auth configs extraordinarily simple to use.
Also changed user_class to user_model - per request from mst.  apparantly class confuses people, a truth I should have realized based on personal experience

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/Changes
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/Changes	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/Changes	2008-10-26 23:27:59 UTC (rev 8572)
@@ -1,11 +1,14 @@
 Revision history for Catalyst-Plugin-Authentication-Store-DBIx-Class
 
-x.xxx   2008-09-25
-        Added missing dependency on Catalyst::Model::DBIC::Schema to Makefile.PL
+0.108   2008-09-25
+		Adding SimpleDB realm to simplify basic auth configuration
+		Changing user_class to user_model, per req. by mst to avoid confusing newbies.
 
 0.107   2008-09-29
-		   - Fix the typo in exception during authenticate
-		   - Doc fixes and clarifications
+		Fix the typo in exception during authenticate
+		Doc fixes and clarifications
+		Added missing dependency on Catalyst::Model::DBIC::Schema to Makefile.PL
+		   
 
 0.105   2008-03-19
         Throw an exception if no fields are provided during authenticate

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/Makefile.PL
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/Makefile.PL	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/Makefile.PL	2008-10-26 23:27:59 UTC (rev 8572)
@@ -31,7 +31,7 @@
 perl_version '5.8.1';
 
 requires (  'Catalyst::Runtime'                 => 0,
-            'Catalyst::Plugin::Authentication'  => '0.10005',
+            'Catalyst::Plugin::Authentication'  => '0.10008',
             'Catalyst::Model::DBIC::Schema'     => 0,
             'DBIx::Class'                       => 0,
 			'Catalyst::Model::DBIC::Schema'		=> '0.18',

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm	2008-10-26 23:27:59 UTC (rev 8572)
@@ -2,7 +2,6 @@
 
 use strict;
 use warnings;
-use Data::Dumper;
 use base qw/Catalyst::Authentication::User/;
 use base qw/Class::Accessor::Fast/;
 
@@ -13,15 +12,25 @@
 sub new {
     my ( $class, $config, $c) = @_;
 
+	if (!defined($config->{'user_model'})) {
+		$config->{'user_model'} = $config->{'user_class'};
+	}
+
     my $self = {
-        resultset => $c->model($config->{'user_class'}),
+        resultset => $c->model($config->{'user_model'}),
         config => $config,
         _roles => undef,
         _user => undef
     };
     
     bless $self, $class;
+
     
+
+    if (not $self->{'resultset'}) {
+        Catalyst::Exception->throw("\$c->model('${ \$self->config->{user_model} }') did not return a resultset. Did you set user_model correctly?");
+    }
+
     ## Note to self- add handling of multiple-column primary keys.
     if (!exists($self->config->{'id_field'})) {
         my @pks = $self->{'resultset'}->result_source->primary_columns;
@@ -31,9 +40,7 @@
             Catalyst::Exception->throw("user table does not contain a single primary key column - please specify 'id_field' in config!");
         }
     }
-    if (not $self->{'resultset'}) {
-        Catalyst::Exception->throw("\$c->model('${ \$self->config->{user_class} }') did not return a resultset. Did you set user_class correctly?");
-    }
+
     if (!$self->{'resultset'}->result_source->has_column($self->config->{'id_field'})) {
         Catalyst::Exception->throw("id_field set to " .  $self->config->{'id_field'} . " but user table has no column by that name!");
     }
@@ -86,7 +93,7 @@
         if (keys %{$searchargs}) {
             $self->_user($self->resultset->search($searchargs)->first);
         } else {
-            Catalyst::Exception->throw("User retrieval failed: no columns from " . $self->config->{'user_class'} . " were provided");
+            Catalyst::Exception->throw("User retrieval failed: no columns from " . $self->config->{'user_model'} . " were provided");
         }
     }
 
@@ -95,7 +102,6 @@
     } else {
         return undef;
     }
-    #$c->log->debug(dumper($self->{'user'}));
 
 }
 

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class.pm
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class.pm	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class.pm	2008-10-26 23:27:59 UTC (rev 8572)
@@ -4,7 +4,7 @@
 use warnings;
 use base qw/Class::Accessor::Fast/;
 
-our $VERSION= "0.107";
+our $VERSION= "0.108";
 
 
 BEGIN {
@@ -112,7 +112,7 @@
                                 },
                                 store => {
                                     class => 'DBIx::Class',
-            	                    user_class => 'MyApp::User',
+            	                    user_model => 'MyApp::User',
             	                    role_relation => 'roles',
             	                    role_field => 'rolename',	                
             	                }
@@ -146,9 +146,10 @@
 =head1 CONFIGURATION
 
 The DBIx::Class authentication store is activated by setting the store
-config's B<class> element to DBIx::Class as shown above.  See the 
-L<Catalyst::Plugin::Authentication> documentation for more details on 
-configuring the store.
+config's B<class> element to DBIx::Class as shown above. See the
+L<Catalyst::Plugin::Authentication> documentation for more details on
+configuring the store. You can also use
+L<Catalyst::Authentication::Realm::SimpleDB> for a simplified setup.
 
 The DBIx::Class storage module has several configuration options
 
@@ -163,7 +164,7 @@
                                 },
                                 store => {
                                     class => 'DBIx::Class',
-            	                    user_class => 'MyApp::User',
+            	                    user_model => 'MyApp::User',
             	                    role_relation => 'roles',
             	                    role_field => 'rolename',
             	                    ignore_fields_in_find => [ 'remote_name' ],
@@ -180,10 +181,12 @@
 Class is part of the core Catalyst::Plugin::Authentication module; it
 contains the class name of the store to be used.
 
-=item user_class
+=item user_model
 
-Contains the class name (as passed to $c->model()) of the DBIx::Class schema
-to use as the source for user information.  This config item is B<REQUIRED>.
+Contains the model name (as passed to $c->model()) of the DBIx::Class schema
+to use as the source for user information. This config item is B<REQUIRED>.
+(Note that this option used to be called user_class. user_class is still
+functional, but should be used only for compatibility with previous configs.)
 
 =item role_column
 
@@ -358,7 +361,7 @@
 The above would allow authentication based on any of the three items -
 username, email, or clientid - and would prefetch the data related to that user
 from the preferences table. The searchargs array is passed directly to the
-search() method associated with the user_class.
+search() method associated with the user_model.
 
 =item Resultset
 
@@ -377,7 +380,7 @@
     } 
 
 Be aware that the resultset method will not verify that you are passing a
-resultset that is attached to the same user_class as specified in the config.
+resultset that is attached to the same user_model as specified in the config.
 
 NOTE: All of these methods of user retrieval, including the resultset method,
 consider the first row returned to be the matching user. In most cases there

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/t/02-pod-coverage.t
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/t/02-pod-coverage.t	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/t/02-pod-coverage.t	2008-10-26 23:27:59 UTC (rev 8572)
@@ -3,4 +3,4 @@
 use Test::More;
 eval "use Test::Pod::Coverage 1.04";
 plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
-all_pod_coverage_ok();
+all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::CountParents' });

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/t/03-authtest.t
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/t/03-authtest.t	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/t/03-authtest.t	2008-10-26 23:27:59 UTC (rev 8572)
@@ -34,7 +34,7 @@
                     },
                     store => {
                         'class' => 'DBIx::Class',
-                        'user_class' => 'TestApp::User',
+                        'user_model' => 'TestApp::User',
                     },
                 },
             },
@@ -94,9 +94,9 @@
 }
 
 {
-    $ENV{TESTAPP_CONFIG}->{authentication}->{realms}->{users}->{store}->{user_class} = 'Nonexistent::Class';
+    $ENV{TESTAPP_CONFIG}->{authentication}->{realms}->{users}->{store}->{user_model} = 'Nonexistent::Class';
     my $res = request('http://localhost/user_login?username=joeuser&password=hackme');
-    like( $res->content, qr/\$\Qc->model('Nonexistent::Class') did not return a resultset. Did you set user_class correctly?/, 'test for wrong user_class' );
+    like( $res->content, qr/\$\Qc->model('Nonexistent::Class') did not return a resultset. Did you set user_model correctly?/, 'test for wrong user_class' );
 }
 	    
 	    

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/t/04-authsessions.t
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/t/04-authsessions.t	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/t/04-authsessions.t	2008-10-26 23:27:59 UTC (rev 8572)
@@ -48,7 +48,7 @@
                     },
                     store => {
                         'class' => 'DBIx::Class',
-                        'user_class' => 'TestApp::User',
+                        'user_model' => 'TestApp::User',
                         'use_userdata_from_session' => 0,
                     },
                 },

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/t/05-auth-roles-relationship.t
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/t/05-auth-roles-relationship.t	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/t/05-auth-roles-relationship.t	2008-10-26 23:27:59 UTC (rev 8572)
@@ -39,7 +39,7 @@
                     },
                     store => {
                         'class' => 'DBIx::Class',
-                        'user_class' => 'TestApp::User',
+                        'user_model' => 'TestApp::User',
                         'role_relation' => 'roles',
                         'role_field' => 'role'
                     },

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/t/06-auth-roles-column.t
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/t/06-auth-roles-column.t	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/t/06-auth-roles-column.t	2008-10-26 23:27:59 UTC (rev 8572)
@@ -39,7 +39,7 @@
                     },
                     store => {
                         'class' => 'DBIx::Class',
-                        'user_class' => 'TestApp::User',
+                        'user_model' => 'TestApp::User',
                         'role_column' => 'role_text'
                     },
                 },

Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/t/07-authsessions-cached.t
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/t/07-authsessions-cached.t	2008-10-22 01:56:46 UTC (rev 8571)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/t/07-authsessions-cached.t	2008-10-26 23:27:59 UTC (rev 8572)
@@ -48,7 +48,7 @@
                     },
                     store => {
                         'class' => 'DBIx::Class',
-                        'user_class' => 'TestApp::User',
+                        'user_model' => 'TestApp::User',
                         'use_userdata_from_session' => 1,
                     },
                 },




More information about the Catalyst-commits mailing list