3 package Catalyst::Plugin::Authentication::Store::Minimal::Backend;
8 use Catalyst::Plugin::Authentication::User::Hash;
12 my ( $class, $hash ) = @_;
14 bless { hash => $hash }, $class;
18 my ( $self, $id ) = @_;
20 return unless exists $self->{hash}{$id};
22 my $user = $self->{hash}{$id};
25 if ( Scalar::Util::blessed($user) ) {
28 elsif ( ref $user eq "HASH" ) {
29 return bless $user, "Catalyst::Plugin::Authentication::User::Hash";
32 Catalyst::Exception->throw( "The user '$id' is a reference of type "
34 . " but should be a HASH" );
38 Catalyst::Exception->throw(
39 "The user '$id' is has to be a hash reference or an object");
48 # choose a random user
49 scalar keys %{ $self->{hash} };
50 ( undef, my $user ) = each %{ $self->{hash} };
63 Catalyst::Plugin::Authentication::Store::Minimal::Backend - Minimal
64 authentication storage backend.
68 # you probably just want Store::Minimal under most cases,
69 # but if you insist you can instantiate your own store:
71 use Catalyst::Plugin::Authentication::Store::Minimal::Backend;
75 Authentication::Credential::Password
79 user => { password => "s3cr3t" },
82 our $users = Catalyst::Plugin::Authentication::Store::Minimal::Backend->new(\%users);
85 my ( $self, $c ) = @_;
87 $c->login( $users->get_user( $c->req->param("login") ),
88 $c->req->param("password") );
93 You probably want L<Catalyst::Plugin::Authentication::Store::Minimal>, unless
94 you are mixing several stores in a single app and one of them is Minimal.
96 Otherwise, this lets you create a store manually.
104 Constructs a new store object, which uses the supplied hash ref as it's backing
109 Keys the hash by $id and returns the value.
111 If the return value is unblessed it will be blessed as
112 L<Catalyst::Plugin::Authentication::User::Hash>.
116 Chooses a random user from the hash and delegates to it.