04b5517978800ad8a7b582842008d5eb6325434f
[catagits/Catalyst-Plugin-Authentication.git] / lib / Catalyst / Authentication / Store / Null.pm
1 package Catalyst::Authentication::Store::Null;
2
3 use strict;
4 use warnings;
5
6 use Catalyst::Authentication::User::Hash;
7
8 use base qw( Class::Accessor::Fast );
9
10 BEGIN {
11     __PACKAGE__->mk_accessors( qw( _config ) );
12 }
13
14 sub new {
15     my ( $class, $config, $app, $realm ) = @_;
16     bless { _config => $config }, $class;
17 }
18
19 sub for_session {
20         my ( $self, $c, $user ) = @_;
21     return $user;
22 }
23
24 sub from_session {
25         my ( $self, $c, $user ) = @_;
26     return $user;
27 }
28
29 sub find_user {
30     my ( $self, $userinfo, $c ) = @_;
31     return bless $userinfo, 'Catalyst::Authentication::User::Hash';
32 }
33
34 sub user_supports {
35     my $self = shift;
36     Catalyst::Authentication::User::Hash->supports(@_);
37 }
38
39 1;
40
41 __END__
42
43 =pod
44
45 =head1 NAME
46
47 Catalyst::Authentication::Store::Null - Null authentication store
48
49 =head1 SYNOPSIS
50
51     use Catalyst qw(
52         Authentication
53     );
54
55     __PACKAGE__->config->{'Plugin::Authentication'} = {
56         default_realm => 'remote',
57         realms => {
58             remote => {
59                 credential => {
60                     class => 'TypeKey',
61                     key_url => 'http://example.com/regkeys.txt',
62                 },
63                 store => {
64                     class => 'Null',
65                 }
66             }
67         }
68     };
69
70 =head1 DESCRIPTION
71
72 The Null store is a transparent store where any supplied user data is
73 accepted. This is mainly useful for remotely authenticating credentials
74 (e.g. TypeKey, OpenID) which may not be tied to any local storage. It also
75 helps facilitate integration with the Session plugin.
76
77 =head1 METHODS
78
79 =head2 new( )
80
81 Creates a new instance of the store.
82
83 =head2 for_session( )
84
85 Returns the user object passed to the method.
86
87 =head2 from_session( )
88
89 Returns the user object passed to the method.
90
91 =head2 find_user( )
92
93 Since this store isn't tied to any real set of users, this method just returns
94 the user info bless as a L<Catalyst::Authentication::User::Hash>
95 object.
96
97 =head2 user_supports( )
98
99 Delegates to L<Catalyst::Authentication::User::Hash>.
100
101 =cut