NAME

OpenInteract::Auth - Authenticate the user object and create its groups

SYNOPSIS

# Authenticate the user based on the session information
# or the login information

OpenInteract::Auth->user;

# Fetch the groups for the logged-in user

OpenInteract::Auth->group;

DESCRIPTION

This class is responsible for authenticating users to the system. It does this in one of two ways:

  1. Find the user_id in their session information and create a user object from it.

  2. Find the $LOGIN_FIELD and $PASSWORD_FIELD arguments passed in via GET/POST and try to create a user with that login name and check the password.

If either of these is successful, then we create a user object and put it into:

$R->{auth}->{user}

where it can be retrieved by all other handlers, modules, etc.

The class also creates an arrayref of groups the user belongs to.

METHODS

Neither of these methods returns a value that reflects what they did. Their success is judged by whether $R has entries for the user and groups.

user()

Creates a user object by whatever means possible and puts it into:

$R->{auth}->{user}

Note that we also set:

$R->{auth}->{logged_in}

which should be used to see whether the user is logged in or not. We will be changing the interface slightly so that you can no longer just check to see if $R->{auth}->{user} is defined. It will be defined with the 'not-logged-in' user to prevent some a nasty bug from happening.

In this method we check to see whether the user has typed in a new username and password. By default, the method will check in the variables 'login_login_name' for the username and 'login_password' for the password. (Both are stored as constants in this module.)

However, you can define your own variable names in your conf/server.perl file. Just set:

{
  login => { login_name => 'xxx',
             password   => 'xxx' },
}

(If you modify the template for logging in to have new names under the 'INPUT' variables you will want to change these.)

group()

If a user object has been created, this fetches the groups the user object belongs to and puts the arrayref of groups into:

$R->{auth}->{group}

TO DO

Ticket handling

We should put checks in here to allow an application to check for expired authentication tickets, or to allow a module to add an authentication handler as a callback which implements its own logic for this.

BUGS

None known.

SEE ALSO

OpenInteract::User

OpenInteract::Group

COPYRIGHT

Copyright (c) 2001 intes.net, inc.. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters <chris@cwinters.com>