3 package Catalyst::Plugin::Authentication;
5 use base qw/Class::Accessor::Fast/;
7 BEGIN { __PACKAGE__->mk_accessors(qw/user/) }
12 sub set_authenticated {
13 my ( $c, $user ) = @_;
17 if ( $c->isa("Catalyst::Plugin::Session")
18 and $c->config->{authentication}{use_session} )
20 $c->session->{__user} = $user->for_session if $user->supperts("session");
21 $c->session->{__user_class} = ref $user;
29 delete @{ $c->session }{qw/__user __user_class/};
33 my $c = shift->NEXT::prepare(@_);
35 if ( $c->isa("Catalyst::Plugin::Session")
36 and $c->config->{authentication}{use_session}
39 if ( $c->sessionid and my $user = $c->session->{__user} ) {
40 $c->user( $c->session->{__user_class}->from_session( $c, $user ) );
50 my $cfg = $c->config->{authentication};
66 Catalyst::Plugin::Authentication -
72 Authentication::Store::Foo
73 Authentication::Credential::Password
78 The authentication plugin is used by the various authentication and
79 authorization plugins in catalyst.
81 It defines the notion of a logged in user, and provides integration with the
89 Delete the currently logged in user from C<user> and the session.
93 Returns the currently logged user or undef if there is none.
97 =head1 INTERNAL METHODS
101 =item set_authenticated $user
103 Marks a user as authenticated. Should be called from a
104 C<Catalyst::Plugin::Authentication::Credential> plugin after successful
107 This involves setting C<user> and the internal data in C<session> if
108 L<Catalyst::Plugin::Session> is loaded.
112 Revives a user from the session object if there is one.
116 Sets the default configuration parameters.
128 Whether or not to store the user's logged in state in the session, if the
129 application is also using the L<Catalyst::Plugin::Authentication> plugin.