[Catalyst-commits] r6563 - in trunk/Catalyst-Plugin-Authentication:
. lib/Catalyst/Plugin lib/Catalyst/Plugin/Authentication t t/lib
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Tue Jul 17 17:59:27 GMT 2007
Author: matthewt
Date: 2007-07-17 17:59:27 +0100 (Tue, 17 Jul 2007)
New Revision: 6563
Added:
trunk/Catalyst-Plugin-Authentication/t/lib/AuthRealmTestApp.pm
Removed:
trunk/Catalyst-Plugin-Authentication/t/AuthRealmTestApp.pm
Modified:
trunk/Catalyst-Plugin-Authentication/
trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm
trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/User.pm
Log:
r53846 at cain (orig r6511): jayk | 2007-07-07 02:05:09 +0000
Moving AuthRealmTestApp.pm to proper directory
Correcting backwards compatibility bug with $user->store()
thanks to nilsonsfj for finding this bug
Property changes on: trunk/Catalyst-Plugin-Authentication
___________________________________________________________________
Name: svk:merge
- 4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Plugin-Authentication:6509
+ 4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Plugin-Authentication:6511
Modified: trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/User.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/User.pm 2007-07-17 16:59:23 UTC (rev 6562)
+++ trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/User.pm 2007-07-17 16:59:27 UTC (rev 6563)
@@ -8,7 +8,7 @@
## auth_realm is the realm this user came from.
BEGIN {
- __PACKAGE__->mk_accessors(qw/auth_realm/);
+ __PACKAGE__->mk_accessors(qw/auth_realm store/);
}
## THIS IS NOT A COMPLETE CLASS! it is intended to provide base functionality only.
@@ -68,10 +68,11 @@
## Backwards Compatibility
## you probably want auth_realm, in fact. but this does work for backwards compatibility.
-sub store {
- my ($self) = @_;
- return $self->auth_realm->{store};
-}
+## store should be a read-write accessor - so it was moved to mk_accessors
+##sub store {
+## my ($self) = @_;
+## return $self->auth_realm->{store};
+##}
__PACKAGE__;
Modified: trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm 2007-07-17 16:59:23 UTC (rev 6562)
+++ trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm 2007-07-17 16:59:27 UTC (rev 6563)
@@ -40,6 +40,7 @@
$c->save_user_in_session($user, $realmname);
}
$user->auth_realm($realmname);
+ $user->store(ref($c->auth_realms->{$realmname}{'store'}));
$c->NEXT::set_authenticated($user, $realmname);
}
@@ -167,6 +168,10 @@
# this sets the realm the user originated in.
$user->auth_realm($realmname);
+ ## compatibility - some pre 0.10 store / credentials may need the store name,
+ ## this is not used by the current api in any form.
+ $user->store(ref($c->auth_realms->{$realmname}{'store'}));
+
return $user;
}
Deleted: trunk/Catalyst-Plugin-Authentication/t/AuthRealmTestApp.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication/t/AuthRealmTestApp.pm 2007-07-17 16:59:23 UTC (rev 6562)
+++ trunk/Catalyst-Plugin-Authentication/t/AuthRealmTestApp.pm 2007-07-17 16:59:27 UTC (rev 6563)
@@ -1,115 +0,0 @@
-package AuthRealmTestApp;
-use warnings;
-use strict;
-
-use Catalyst qw/Authentication/;
-
-use Test::More;
-use Test::Exception;
-
-our $members = {
- bob => {
- password => "s00p3r"
- },
- william => {
- password => "s3cr3t"
- }
-};
-
-our $admins = {
- joe => {
- password => "31337"
- }
-};
-
-sub moose : Local {
- my ( $self, $c ) = @_;
-
- ok(!$c->user, "no user");
-
- while ( my ($user, $info) = each %$members ) {
-
- ok(
- $c->authenticate(
- { username => $user, password => $info->{password} },
- 'members'
- ),
- "user $user authentication"
- );
-
- # check existing realms
- ok( $c->user_in_realm('members'), "user in members realm");
- ok(!$c->user_in_realm('admins'), "user not in admins realm");
-
- # check an invalid realm
- ok(!$c->user_in_realm('foobar'), "user not in foobar realm");
-
- # check if we've got the right user
- is( $c->user, $info, "user object is in proper place");
-
- $c->logout;
-
- # sanity check
- ok(!$c->user, "no more user after logout");
-
- }
-
- while ( my ($user, $info) = each %$admins ) {
-
- ok(
- $c->authenticate(
- { username => $user, password => $info->{password} },
- 'admins'
- ),
- "user $user authentication"
- );
-
- # check existing realms
- ok(!$c->user_in_realm('members'), "user not in members realm");
- ok( $c->user_in_realm('admins'), "user in admins realm");
-
- # check an invalid realm
- ok(!$c->user_in_realm('foobar'), "user not in foobar realm");
-
- # check if we've got the right user
- is( $c->user, $info, "user object is in proper place");
-
- $c->logout;
-
- # sanity check
- ok(!$c->user, "no more user after logout");
-
- }
-
- $c->res->body( "ok" );
-}
-
-__PACKAGE__->config->{authentication} = {
- default_realm => 'members',
- realms => {
- members => {
- credential => {
- class => 'Password',
- password_field => 'password',
- password_type => 'clear'
- },
- store => {
- class => 'Minimal',
- users => $members
- }
- },
- admins => {
- credential => {
- class => 'Password',
- password_field => 'password',
- password_type => 'clear'
- },
- store => {
- class => 'Minimal',
- users => $admins
- }
- }
- }
-};
-
-__PACKAGE__->setup;
Added: trunk/Catalyst-Plugin-Authentication/t/lib/AuthRealmTestApp.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication/t/lib/AuthRealmTestApp.pm (rev 0)
+++ trunk/Catalyst-Plugin-Authentication/t/lib/AuthRealmTestApp.pm 2007-07-17 16:59:27 UTC (rev 6563)
@@ -0,0 +1,115 @@
+package AuthRealmTestApp;
+use warnings;
+use strict;
+
+use Catalyst qw/Authentication/;
+
+use Test::More;
+use Test::Exception;
+
+our $members = {
+ bob => {
+ password => "s00p3r"
+ },
+ william => {
+ password => "s3cr3t"
+ }
+};
+
+our $admins = {
+ joe => {
+ password => "31337"
+ }
+};
+
+sub moose : Local {
+ my ( $self, $c ) = @_;
+
+ ok(!$c->user, "no user");
+
+ while ( my ($user, $info) = each %$members ) {
+
+ ok(
+ $c->authenticate(
+ { username => $user, password => $info->{password} },
+ 'members'
+ ),
+ "user $user authentication"
+ );
+
+ # check existing realms
+ ok( $c->user_in_realm('members'), "user in members realm");
+ ok(!$c->user_in_realm('admins'), "user not in admins realm");
+
+ # check an invalid realm
+ ok(!$c->user_in_realm('foobar'), "user not in foobar realm");
+
+ # check if we've got the right user
+ is( $c->user, $info, "user object is in proper place");
+
+ $c->logout;
+
+ # sanity check
+ ok(!$c->user, "no more user after logout");
+
+ }
+
+ while ( my ($user, $info) = each %$admins ) {
+
+ ok(
+ $c->authenticate(
+ { username => $user, password => $info->{password} },
+ 'admins'
+ ),
+ "user $user authentication"
+ );
+
+ # check existing realms
+ ok(!$c->user_in_realm('members'), "user not in members realm");
+ ok( $c->user_in_realm('admins'), "user in admins realm");
+
+ # check an invalid realm
+ ok(!$c->user_in_realm('foobar'), "user not in foobar realm");
+
+ # check if we've got the right user
+ is( $c->user, $info, "user object is in proper place");
+
+ $c->logout;
+
+ # sanity check
+ ok(!$c->user, "no more user after logout");
+
+ }
+
+ $c->res->body( "ok" );
+}
+
+__PACKAGE__->config->{authentication} = {
+ default_realm => 'members',
+ realms => {
+ members => {
+ credential => {
+ class => 'Password',
+ password_field => 'password',
+ password_type => 'clear'
+ },
+ store => {
+ class => 'Minimal',
+ users => $members
+ }
+ },
+ admins => {
+ credential => {
+ class => 'Password',
+ password_field => 'password',
+ password_type => 'clear'
+ },
+ store => {
+ class => 'Minimal',
+ users => $admins
+ }
+ }
+ }
+};
+
+__PACKAGE__->setup;
More information about the Catalyst-commits
mailing list