From: Jay Kuri Date: Thu, 24 Jan 2008 20:55:39 +0000 (+0000) Subject: Update to correct behavior when using the new 'Plugin::Authentication' X-Git-Tag: v0.10009_01~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c4d44afd622b1189bc4c1f51d3e6d96d9ca5287;hp=a3b606d427033546952126878ec39972ba1dd02a;p=catagits%2FCatalyst-Plugin-Authentication.git Update to correct behavior when using the new 'Plugin::Authentication' configuration naming scheme. --- diff --git a/lib/Catalyst/Authentication/Credential/Password.pm b/lib/Catalyst/Authentication/Credential/Password.pm index 55f70fd..4697a1a 100644 --- a/lib/Catalyst/Authentication/Credential/Password.pm +++ b/lib/Catalyst/Authentication/Credential/Password.pm @@ -236,7 +236,7 @@ provided against the user retrieved from the store. =head1 CONFIGURATION # example - __PACKAGE__->config->{authentication} = + __PACKAGE__->config->{'Plugin::Authentication'} = { default_realm => 'members', realms => { diff --git a/lib/Catalyst/Authentication/Store/Minimal.pm b/lib/Catalyst/Authentication/Store/Minimal.pm index ba54f6a..155a921 100644 --- a/lib/Catalyst/Authentication/Store/Minimal.pm +++ b/lib/Catalyst/Authentication/Store/Minimal.pm @@ -79,7 +79,7 @@ sub setup { $c->default_auth_store( __PACKAGE__->new( - $c->config->{authentication}, $c + $c->config->{'Plugin::Authentication'}, $c ) ); @@ -107,7 +107,7 @@ Catalyst::Authentication::Store::Minimal - Minimal authentication store Authentication /; - __PACKAGE__->config->{authentication} = + __PACKAGE__->config->{'Plugin::Authentication'} = { default_realm => 'members', realms => { diff --git a/lib/Catalyst/Authentication/Store/Null.pm b/lib/Catalyst/Authentication/Store/Null.pm index 7533d50..04b5517 100644 --- a/lib/Catalyst/Authentication/Store/Null.pm +++ b/lib/Catalyst/Authentication/Store/Null.pm @@ -52,7 +52,7 @@ Catalyst::Authentication::Store::Null - Null authentication store Authentication ); - __PACKAGE__->config->{authentication} = { + __PACKAGE__->config->{'Plugin::Authentication'} = { default_realm => 'remote', realms => { remote => { diff --git a/lib/Catalyst/Plugin/Authentication.pm b/lib/Catalyst/Plugin/Authentication.pm index d4cacc6..4861d93 100644 --- a/lib/Catalyst/Plugin/Authentication.pm +++ b/lib/Catalyst/Plugin/Authentication.pm @@ -20,7 +20,7 @@ use Catalyst::Authentication::Realm; # constant->import(have_want => eval { require Want }); #} -our $VERSION = "0.10004"; +our $VERSION = "0.10005"; sub set_authenticated { my ( $c, $user, $realmname ) = @_; @@ -39,7 +39,7 @@ sub set_authenticated { } if ( $c->isa("Catalyst::Plugin::Session") - and $c->config->{authentication}{use_session} + and $c->config->{'Plugin::Authentication'}{'use_session'} and $user->supports("session") ) { $realm->save_user_in_session($c, $user); @@ -107,7 +107,7 @@ sub logout { if ( $c->isa("Catalyst::Plugin::Session") - and $c->config->{authentication}{use_session} + and $c->config->{'Plugin::Authentication'}{'use_session'} and $c->session_is_valid ) { delete @{ $c->session }{qw/__user __user_realm/}; @@ -135,7 +135,7 @@ sub _user_in_session { return unless $c->isa("Catalyst::Plugin::Session") - and $c->config->{authentication}{use_session} + and $c->config->{'Plugin::Authentication'}{'use_session'} and $c->session_is_valid; return $c->session->{__user}; @@ -179,9 +179,21 @@ sub _authentication_initialize { ## make classdata where it is used. $app->mk_classdata( '_auth_realms' => {}); - my $cfg = $app->config->{'Plugin::Authentication'} ||= $app->config->{'authentication'} ||= {}; + my $cfg = $app->config->{'Plugin::Authentication'}; + if (!defined($cfg)) { + if (exists($app->config->{'authentication'})) { + $cfg = $app->config->{'authentication'}; + $app->config->{'Plugin::Authentication'} = $app->config->{'authentication'}; + } else { + $cfg = {}; + } + } - $cfg->{use_session} = 1; + # old default was to force use_session on. This must remain for that + # reason - but if use_session is already in the config, we respect it's setting. + if (!exists($cfg->{'use_session'})) { + $cfg->{'use_session'} = 1; + } if (exists($cfg->{'realms'})) { foreach my $realm (keys %{$cfg->{'realms'}}) { @@ -514,7 +526,7 @@ This means that our application will begin like this: Authentication /; - __PACKAGE__->config->{authentication} = + __PACKAGE__->config->{'Plugin::Authentication'} = { default_realm => 'members', realms => { @@ -636,7 +648,7 @@ efficient to maintain a hash of users, so you move this data to a database. You can accomplish this simply by installing the DBIx::Class Store and changing your config: - __PACKAGE__->config->{authentication} = + __PACKAGE__->config->{'Plugin::Authentication'} = { default_realm => 'members', realms => { @@ -662,7 +674,7 @@ new source. The rest of your application is completely unchanged. =head1 CONFIGURATION # example - __PACKAGE__->config->{authentication} = + __PACKAGE__->config->{'Plugin::Authentication'} = { default_realm => 'members', realms => { @@ -887,7 +899,7 @@ included here for reference only. Return the store whose name is 'default'. -This is set to C<< $c->config->{authentication}{store} >> if that value exists, +This is set to C<< $c->config->{'Plugin::Authentication'}{store} >> if that value exists, or by using a Store plugin: # load the Minimal authentication store. diff --git a/t/lib/AuthSessionTestApp.pm b/t/lib/AuthSessionTestApp.pm index 35518cc..e3f3680 100644 --- a/t/lib/AuthSessionTestApp.pm +++ b/t/lib/AuthSessionTestApp.pm @@ -68,7 +68,7 @@ sub butterfly : Local { ok( !$c->user, "no user object either" ); } -__PACKAGE__->config->{authentication}{users} = $users = { +__PACKAGE__->config->{'Plugin::Authentication'}{users} = $users = { foo => User::SessionRestoring->new( id => 'foo', password => "s3cr3t", diff --git a/t/lib/AuthTestApp.pm b/t/lib/AuthTestApp.pm index c8a92e8..1c43cd1 100644 --- a/t/lib/AuthTestApp.pm +++ b/t/lib/AuthTestApp.pm @@ -52,7 +52,7 @@ sub moose : Local { $c->res->body( "ok" ); } -__PACKAGE__->config->{authentication}{users} = $users = { +__PACKAGE__->config->{'Plugin::Authentication'}{users} = $users = { foo => { password => "s3cr3t", },