Commit | Line | Data |
06675d2e |
1 | #!/usr/bin/perl |
2 | |
3 | package Catalyst::Plugin::Authentication::Store::Minimal; |
06675d2e |
4 | |
5 | use strict; |
6 | use warnings; |
7 | |
8 | use Catalyst::Plugin::Authentication::Store::Minimal::Backend; |
9 | |
10 | sub setup { |
11 | my $c = shift; |
12 | |
b003080b |
13 | $c->default_auth_store( |
54c8dc06 |
14 | Catalyst::Plugin::Authentication::Store::Minimal::Backend->new( |
62f27384 |
15 | $c->config->{authentication}, $c |
b003080b |
16 | ) |
17 | ); |
06675d2e |
18 | |
b003080b |
19 | $c->NEXT::setup(@_); |
06675d2e |
20 | } |
21 | |
22 | __PACKAGE__; |
23 | |
24 | __END__ |
25 | |
26 | =pod |
27 | |
28 | =head1 NAME |
29 | |
30 | Catalyst::Plugin::Authentication::Store::Minimal - Authentication |
3bb6fd27 |
31 | database in C<< $c->config >>. |
06675d2e |
32 | |
33 | =head1 SYNOPSIS |
34 | |
35 | use Catalyst qw/ |
36 | Authentication |
37 | Authentication::Store::Minimal |
38 | Authentication::Credential::Password |
39 | /; |
40 | |
41 | __PACKAGE__->config->{authentication}{users} = { |
42 | name => { |
43 | password => "s3cr3t", |
44 | roles => [qw/admin editor/], |
45 | ... |
46 | }, |
47 | }; |
48 | |
49 | sub login : Global { |
50 | my ( $self, $c ) = @_; |
51 | |
52 | $c->login( $c->req->param("login"), $c->req->param("password"), ); |
53 | } |
54 | |
55 | =head1 DESCRIPTION |
56 | |
57 | This authentication store plugin lets you create a very quick and dirty user |
58 | database in your application's config hash. |
59 | |
3bb6fd27 |
60 | You will need to include the Authentication plugin, and at least one Credential |
61 | plugin to use this Store. Credential::Password is reccommended. |
62 | |
06675d2e |
63 | It's purpose is mainly for testing, and it should probably be replaced by a |
64 | more "serious" store for production. |
65 | |
66 | The hash in the config, as well as the user objects/hashes are freely mutable |
67 | at runtime. |
68 | |
3bb6fd27 |
69 | =head1 CONFIGURATION |
70 | |
71 | =over 4 |
72 | |
73 | =item users |
74 | |
75 | This is a simple hash of users, the keys are the usenames, and the values are |
76 | hashrefs containing a password key/value pair, and optionally, a roles/list |
77 | of role-names pair. If using roles, you will also need to add the |
78 | Authorization::Roles plugin. |
79 | |
80 | See the SYNOPSIS for an example. |
81 | |
2bcde605 |
82 | =back |
83 | |
3bb6fd27 |
84 | =head1 INTERNAL METHODS |
06675d2e |
85 | |
86 | =over 4 |
87 | |
88 | =item setup |
89 | |
90 | This method will popultate C<< $c->config->{authentication}{store} >> so that |
7d0922d8 |
91 | L<Catalyst::Plugin::Authentication/default_auth_store> can use it. |
06675d2e |
92 | |
93 | =back |
94 | |
95 | =cut |
96 | |
97 | |