3 package Catalyst::Plugin::Authentication::User;
7 use base qw/Class::Accessor::Fast/;
9 ## auth_realm is the realm this user came from.
11 __PACKAGE__->mk_accessors(qw/auth_realm/);
14 ## THIS IS NOT A COMPLETE CLASS! it is intended to provide base functionality only.
15 ## translation - it won't work if you try to use it directly.
17 ## chances are you want to override this.
18 sub id { shift->get('id'); }
20 ## this relies on 'supported_features' being implemented by the subclass..
21 ## but it is not an error if it is not. it just means you support nothing.
22 ## nihilist user objects are welcome here.
24 my ( $self, @spec ) = @_;
27 if ($self->can('supported_features')) {
28 $cursor = $self->supported_features;
30 # traverse the feature list,
32 #die "bad feature spec: @spec" if ref($cursor) ne "HASH";
33 return if ref($cursor) ne "HASH";
35 $cursor = $cursor->{$_};
43 ## get should return the value of the field specified as it's single argument from the underlying
44 ## user object. This is here to provide a simple, standard way of accessing individual elements of a user
45 ## object - ensuring no overlap between C::P::A::User methods and actual fieldnames.
46 ## this is not the most effecient method, since it uses introspection. If you have an underlying object
47 ## you most likely want to write this yourself.
49 my ($self, $field) = @_;
52 if ($object = $self->get_object and $object->can($field)) {
53 return $object->$field();
60 ## get_object should return the underlying user object. This is for when more advanced uses of the
61 ## user is required. Modifications to the existing user, etc. Changes in the object returned
62 ## by this routine may not be reflected in the C::P::A::User object - if this is required, re-authenticating
63 ## the user is probably the best route to take.
64 ## note that it is perfectly acceptable to return $self in cases where there is no underlying object.
69 ## Backwards Compatibility
70 ## you probably want auth_realm, in fact. but this does work for backwards compatibility.
73 return $self->auth_realm->{store};
84 Catalyst::Plugin::Authentication::User - Base class for user objects.
88 package MyStore::User;
89 use base qw/Catalyst::Plugin::Authentication::User/;
93 This is the base class for authenticated
101 A unique ID by which a user can be retrieved from the store.
105 Should return a class name that can be used to refetch the user using it's
110 An introspection method used to determine what features a user object has, to support credential and authorization plugins.