[Catalyst-commits] r7518 - in
trunk/Catalyst-Plugin-Authentication/lib/Catalyst:
Authentication Authentication/Realm Plugin
jayk at dev.catalyst.perl.org
jayk at dev.catalyst.perl.org
Thu Mar 20 21:04:17 GMT 2008
Author: jayk
Date: 2008-03-20 21:04:17 +0000 (Thu, 20 Mar 2008)
New Revision: 7518
Modified:
trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Authentication/Realm.pm
trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Authentication/Realm/Compatibility.pm
trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm
Log:
allow the realm to use session even if main auth module doesn't
IF configured to do so.
also - fix some documentation problems
Modified: trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Authentication/Realm/Compatibility.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Authentication/Realm/Compatibility.pm 2008-03-20 12:12:13 UTC (rev 7517)
+++ trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Authentication/Realm/Compatibility.pm 2008-03-20 21:04:17 UTC (rev 7518)
@@ -14,6 +14,7 @@
my $self = { config => $config };
bless $self, $class;
+ $self->config->{'use_session'} = $app->config->{'Plugin::Authentication'}{'use_session'} || '1';
$self->name($realmname);
return $self;
Modified: trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Authentication/Realm.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Authentication/Realm.pm 2008-03-20 12:12:13 UTC (rev 7517)
+++ trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Authentication/Realm.pm 2008-03-20 21:04:17 UTC (rev 7518)
@@ -9,6 +9,8 @@
__PACKAGE__->mk_accessors(qw/store credential name config/);
};
+## Add use_session config item to realm.
+
sub new {
my ($class, $realmname, $config, $app) = @_;
@@ -17,6 +19,14 @@
$self->name($realmname);
+ if (!exists($self->config->{'use_session'})) {
+ if (exists($app->config->{'Plugin::Authentication'}{'use_session'})) {
+ $self->config->{'use_session'} = $app->config->{'Plugin::Authentication'}{'use_session'};
+ } else {
+ $self->config->{'use_session'} = 1;
+ }
+ }
+ print STDERR "use session is " . $self->config->{'use_session'} . "\n";
$app->log->debug("Setting up auth realm $realmname") if $app->debug;
# use the Null store as a default
@@ -150,7 +160,7 @@
return unless
$c->isa("Catalyst::Plugin::Session")
- and $c->config->{'Plugin::Authentication'}{'use_session'}
+ and $self->config->{'use_session'}
and $c->session_is_valid;
return $c->session->{__user};
@@ -175,7 +185,7 @@
if (
$c->isa("Catalyst::Plugin::Session")
- and $c->config->{'Plugin::Authentication'}{'use_session'}
+ and $self->config->{'use_session'}
and $user->supports("session")
) {
$c->session->{__user_realm} = $self->name;
@@ -197,7 +207,7 @@
if (
$c->isa("Catalyst::Plugin::Session")
- and $c->config->{'Plugin::Authentication'}{'use_session'}
+ and $self->config->{'use_session'}
and $c->session_is_valid
) {
delete @{ $c->session }{qw/__user __user_realm/};
Modified: trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm 2008-03-20 12:12:13 UTC (rev 7517)
+++ trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm 2008-03-20 21:04:17 UTC (rev 7518)
@@ -13,19 +13,7 @@
use Class::Inspector;
use Catalyst::Authentication::Realm;
-# this optimization breaks under Template::Toolkit
-# use user_exists instead
-#BEGIN {
-# require constant;
-# constant->import(have_want => eval { require Want });
-#}
-## NOTE TO SELF:
-## move user persistence into realm.
-## basically I'll provide 'persist_user' which will save the currently auth'd user.
-## 'restore_user' which will restore the user, and 'user_is_restorable' which is a
-## true/false on whether there is a user to restore.
-
our $VERSION = "0.11000";
sub set_authenticated {
@@ -306,6 +294,7 @@
my $realmcfg = {
store => { class => $cfg->{'stores'}{$storename} },
};
+ print STDERR "Foo, ok?\n";
$app->setup_auth_realm($storename, $realmcfg);
}
}
@@ -733,7 +722,7 @@
sub edit : Local {
my ( $self, $c ) = @_;
- $c->detach("unauthorized") unless $c->check_roles("edit");
+ $c->detach("unauthorized") unless $c->check_user_roles("edit");
# do something restricted here
}
More information about the Catalyst-commits
mailing list