From: Jay Kuri Date: Thu, 27 Nov 2008 23:49:56 +0000 (+0000) Subject: adding progressive realm. planning for launch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2c8686a15b41da153a85228f6a9bd73367665e1b;p=catagits%2FCatalyst-Plugin-Authentication.git adding progressive realm. planning for launch --- diff --git a/Changes b/Changes index ab6bb59..96ec29e 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,10 @@ Revision history for Perl extension Catalyst::Plugin::Authentication -0.10007 2008-10-23 +0.10009 2008-11-27 + - Including progressive realm for multiple authentication attempts + in a single request. + +0.10008 2008-10-23 - Updating config to allow for inclusion of realm ref's in the main config hash rather than in a subref called 'realms' diff --git a/lib/Catalyst/Authentication/Realm/Progressive.pm b/lib/Catalyst/Authentication/Realm/Progressive.pm index 122dcbc..4390f45 100644 --- a/lib/Catalyst/Authentication/Realm/Progressive.pm +++ b/lib/Catalyst/Authentication/Realm/Progressive.pm @@ -12,13 +12,18 @@ Catalyst::Authentication::Realm::Progressive - Authenticate against multiple rea =head1 SYNOPSIS -This Realm allows an application to be built so that multiple realms are -supported and tried incrementally until a successful authentication. +This Realm allows an application to use a single authenticate() call during +which multiple realms are used and tried incrementally until one performs +a successful authentication is accomplished. -A simple use case is a Temporary Password that looks and acts exactly as a -regular password. Without changing the authentication code, you can +A simple use case is a Temporary Password that looks and acts exactly as a +regular password. Without changing the authentication code, you can authenticate against multiple realms. +Another use might be to support a legacy website authentication system, trying +the current auth system first, and upon failure, attempting authentication against +the legacy system. + =head2 EXAMPLE If your application has multiple realms to authenticate, such as a temporary @@ -36,8 +41,8 @@ the normal realm. # Modify the authinfo passed into authenticate by merging # these hashes into the realm's authenticate call: authinfo_munge => { - 'local' => { 'realm' => 'normal' }, - 'temp' => { 'realm' => 'temp' }, + 'local' => { 'type' => 'normal' }, + 'temp' => { 'type' => 'temporary' }, } }, 'normal' => { @@ -74,7 +79,7 @@ Then, in your controller code, to attempt authentication against both realms you just have to do a simple authenticate call: if ( $c->authenticate({ id => $username, password => $password }) ) { - if ( $c->user->realm eq 'temp' ) { + if ( $c->user->type eq 'temporary' ) { # Force user to change password } } diff --git a/lib/Catalyst/Plugin/Authentication.pm b/lib/Catalyst/Plugin/Authentication.pm index 0774362..49ca595 100644 --- a/lib/Catalyst/Plugin/Authentication.pm +++ b/lib/Catalyst/Plugin/Authentication.pm @@ -13,7 +13,7 @@ use Tie::RefHash; use Class::Inspector; use Catalyst::Authentication::Realm; -our $VERSION = "0.10008"; +our $VERSION = "0.10009"; sub set_authenticated { my ( $c, $user, $realmname ) = @_;