
Mango::Catalyst::Plugin::Authentication - Custom Catalyst Authentication Plugin

use Catalyst qw/
-Debug
ConfigLoader
+Mango::Catalyst::Plugin::Application
Static::Simple
/;

Mango::Catalyst::Plugin::Authentication is a subclass of Catalyst::Plugin::Authentication that attempts to present authenticated and anonymous user information in the same way:
# anonymous user
$c->user->username; # anonymous
$c->user->profile->first_name # Anonymous
$c->user->cart->count;
# authenticated user
$c->user->username; # claco
$c->user->profile->first_name # Christopher
$c->user->cart->count;
When authenticating users, the mango realm will be used, which in turn uses Mango::Catalyst::Plugin::Authentication::Store to authenticate users.
This plugin also supports HTTP Authentication using Basic and Digest.

The following configuration is considered the default when loading Mango::Catalyst::Plugin::Authentication:
authentication:
default_realm: mango
realms:
mango:
credential:
class: Password
password_field: password
password_type: clear
store:
class: +Mango::Catalyst::Plugin::Authentication::Store
cart_model: Carts
profile_model: Profiles
role_model: Roles
user_model: Users
If the default_realm is not mango or no realm named mango is configured, all calls to "user" simply return what the normal authentication process would return. For now, this means that any piece of code relying on the Mango specific helpers (c->user->cart, etc) will crash and burn. This may be fixed in later release with some elfin magic.
See Mango::Catalyst::Plugin::Authentication::Store for further information about what the available configuration options mean.

Authenticates the user using the specified username/password:
if ($c->authenticate({
username => $username,
password => $password
})) {
...
};
If not information is supplied, HTTP Authentication will be tried instead:
if ($c->authenticate) {
...
};
Returns true if the current user is authenticate and is the admin role. This should probably be moved into the custom user subclass.
Sets the template and http status to 401 Unauthorized.
Returns a Mango authentication user object for the current web user. If the current user isn't authenticated, an AnonymousUser object will be returned. If the user has just been authenticated, a User object will be returned. If the current user has already been authenticated, a CachedUser will be returned.
## AnonymousUser pre auth
my $user = $c->user;
## User from auth
my $user = $c->authenticate(...);
## CachedUser after auth
my $user = $c->user;
See the User, CachedUser and AnonymousUser for more information about the difference between the different user classes.

Catalyst::Plugin::Authentication, Mango::Catalyst::Plugin::Authentication::Store Mango::Catalyst::Plugin::Authentication::User Mango::Catalyst::Plugin::Authentication::CachedUser Mango::Catalyst::Plugin::Authentication::AnonymousUser

Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/