Auth
[ class tree: Auth ] [ index: Auth ] [ all elements ]

Class: Auth

Source Location: /Auth-1.3.0r2/Auth.php

Class Overview


PEAR::Auth


Author(s):

Version:

  • $Revision: 1.86 $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 38]
PEAR::Auth

The PEAR::Auth class provides methods for creating an authentication system using PHP.

  • Author: Martin Jansen <mj@php.net>
  • Version: $Revision: 1.86 $


[ Top ]


Class Variables

$advancedsecurity =  false

[line 176]

Flag to use advanced security When set extra checks will be made to see if the user's IP or useragent have changed across requests.

Turned off by default to preserve BC.


Type:   boolean


[ Top ]

$allowLogin =  true

[line 107]

Is Login Allowed from this page

Type:   bool


[ Top ]

$authChecks =  0

[line 226]

How many times has checkAuth been called

var int


Type:   mixed


[ Top ]

$authdata =

[line 220]

A hash to hold various superglobals as reference

Type:   array


[ Top ]

$cookie =

[line 214]

Holds a reference to the global cookie variable

Type:   array


[ Top ]

$expire =  0

[line 48]

Auth lifetime in seconds

If this variable is set to 0, auth never expires


Type:   integer


[ Top ]

$expired =  false

[line 56]

Has the auth session expired?
  • See: checkAuth()

Type:   bool


[ Top ]

$idle =  0

[line 68]

Maximum idletime in seconds

The difference to $expire is, that the idletime gets refreshed each time checkAuth() is called. If this variable is set to 0, idletime is never checked.


Type:   integer


[ Top ]

$idled =  false

[line 76]

Is the maximum idletime over?
  • See: checkAuth()

Type:   boolean


[ Top ]

$loginCallback =  ''

[line 136]

Login callback function name

Type:   string


[ Top ]

$loginFailedCallback =  ''

[line 144]

Failed Login callback function name
  • See: setLoginFailedCallback()

Type:   string


[ Top ]

$loginFunction =  ''

[line 91]

User-defined function that creates the login screen

Type:   string


[ Top ]

$logoutCallback =  ''

[line 152]

Logout callback function name

Type:   string


[ Top ]

$password =  ''

[line 128]

Password

Type:   string


[ Top ]

$post =

[line 208]

Holds a reference to the global post variable

Type:   array


[ Top ]

$server =

[line 202]

Holds a reference to the global server variable

Type:   array


[ Top ]

$session =

[line 196]

Holds a reference to the session auth variable

Type:   array


[ Top ]

$showLogin =  true

[line 99]

Should the login form be displayed
  • See: setShowlogin()

Type:   bool


[ Top ]

$status =  ''

[line 114]

Current authentication status

Type:   string


[ Top ]

$storage =  ''

[line 84]

Storage object

Type:   object


[ Top ]

$username =  ''

[line 121]

Username

Type:   string


[ Top ]

$version =  "@version@"

[line 166]

Package Version

Type:   string


[ Top ]



Method Detail

Auth (Constructor)   [line 242]

void Auth( string $storageDriver, [mixed $options = ''], [string $loginFunction = ''], [boolean $showLogin = true])

Constructor

Set up the storage driver.


Parameters:

string   $storageDriver   —  Type of the storage driver
mixed   $options   —  Additional options for the storage driver (example: if you are using DB as the storage driver, you have to pass the dsn string here)
string   $loginFunction   —  Name of the function that creates the login form
boolean   $showLogin   —  Should the login form be displayed if neccessary?

[ Top ]

addUser   [line 840]

mixed addUser( string $username, string $password, [mixed $additional = ''])

Add user to the storage container
  • Return: True on success, PEAR error object on error and AUTH_METHOD_NOT_SUPPORTED otherwise.
  • Access: public

Parameters:

string   $username   —  Username
string   $password   —  Password
mixed   $additional   —  Additional parameters

[ Top ]

applyAuthOptions   [line 290]

array &applyAuthOptions( array &$options)

Set the Auth options

Some options which are Auth specific will be applied the rest will be left for usage by the container

  • Return: The options which were not applied

Parameters:

array   &$options   —  An array of Auth options

[ Top ]

changePassword   [line 869]

mixed changePassword( string $username, string $password)

Change password for user in the storage container
  • Return: True on success, PEAR error object on error and AUTH_METHOD_NOT_SUPPORTED otherwise.
  • Access: public

Parameters:

string   $username   —  Username
string   $password   —  The new password

[ Top ]

getAuth   [line 719]

bool getAuth( )

Has the user been authenticated?
  • Return: True if the user is logged in, otherwise false.
  • Access: public

[ Top ]

getAuthData   [line 562]

mixed getAuthData( [string $name = null])

Get additional information that is stored in the session.

If no value for the first parameter is passed, the method will return all data that is currently stored.

  • Return: Value of the data field.
  • Access: public

Parameters:

string   $name   —  Name of the data field

[ Top ]

getPostPasswordField   [line 799]

string getPostPasswordField( )

Gets the post varible used for the username
  • Access: public

[ Top ]

getPostUsernameField   [line 789]

string getPostUsernameField( )

Gets the post varible used for the username
  • Access: public

[ Top ]

getStatus   [line 778]

string getStatus( )

Get the current status
  • Access: public

[ Top ]

getUsername   [line 764]

string getUsername( )

Get the username
  • Access: public

[ Top ]

listUsers   [line 824]

array listUsers( )

List all users that are currently available in the storage container
  • Access: public

[ Top ]

logout   [line 736]

void logout( )

Logout function

This function clears any auth tokens in the currently active session and executes the logout callback function, if any

  • Access: public

[ Top ]

removeUser   [line 854]

mixed removeUser( string $username)

Remove user from the storage container
  • Return: True on success, PEAR error object on error and AUTH_METHOD_NOT_SUPPORTED otherwise.
  • Access: public

Parameters:

string   $username   —  Username

[ Top ]

sessionValidThru   [line 809]

integer sessionValidThru( )

Returns the time up to the session is valid
  • Access: public

[ Top ]

setAdvancedSecurity   [line 619]

void setAdvancedSecurity( [bool $flag = true])

Enables advanced security checks

Currently only ip change and useragent change are detected

  • Todo: Add challenge cookies - Create a cookie which changes every time and contains some challenge key which the server can verify with a session var cookie might need to be crypted (user pass)
  • Access: public

Parameters:

bool   $flag   —  Enable or disable

[ Top ]

setAllowLogin   [line 492]

void setAllowLogin( [bool $allowLogin = true])

Should the login form be displayed if neccessary?
  • Access: public

Parameters:

bool   $allowLogin   —  show login form or not

[ Top ]

setAuth   [line 580]

void setAuth( string $username)

Register variable in a session telling that the user has logged in successfully
  • Access: public

Parameters:

string   $username   —  Username

[ Top ]

setAuthData   [line 545]

void setAuthData( string $name, mixed $value, [boolean $overwrite = true])

Register additional information that is to be stored in the session.
  • Access: public

Parameters:

string   $name   —  Name of the data field
mixed   $value   —  Value of the data field
boolean   $overwrite   —  Should existing data be overwritten? (default is true)

[ Top ]

setExpire   [line 443]

void setExpire( integer $time, [bool $add = false])

Set the maximum expire time
  • Access: public

Parameters:

integer   $time   —  time in seconds
bool   $add   —  add time to current expire time or not

[ Top ]

setFailedLoginCallback   [line 517]

void setFailedLoginCallback( string $loginFailedCallback)

Register a callback function to be called on failed user login.

The function will receive a single parameter, the username and a reference to the auth object.

  • Access: public

Parameters:

string   $loginFailedCallback   —  callback function name

[ Top ]

setIdle   [line 455]

void setIdle( integer $time, [bool $add = false])

Set the maximum idle time
  • Access: public

Parameters:

integer   $time   —  time in seconds
bool   $add   —  add time to current maximum idle time or not

[ Top ]

setLoginCallback   [line 505]

void setLoginCallback( string $loginCallback)

Register a callback function to be called on user login.

The function will receive two parameters, the username and a reference to the auth object.


Parameters:

string   $loginCallback   —  callback function name

[ Top ]

setLogoutCallback   [line 530]

void setLogoutCallback( string $logoutCallback)

Register a callback function to be called on user logout.

The function will receive three parameters, the username and a reference to the auth object.


Parameters:

string   $logoutCallback   —  callback function name

[ Top ]

setSessionname   [line 470]

void setSessionname( [string $name = 'PHPSESSID'])

Set name of the session to a customized value.

If you are using multiple instances of PEAR::Auth on the same domain, you can change the name of session per application via this function.

  • Access: public

Parameters:

string   $name   —  New name for the session

[ Top ]

setShowLogin   [line 481]

void setShowLogin( [bool $showLogin = true])

Should the login form be displayed if neccessary?
  • Access: public

Parameters:

bool   $showLogin   —  show login form or not

[ Top ]

start   [line 375]

void start( )

Start new auth session
  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 13:52:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.