Authentication: ezcAuthentication
[ ]
[ Rfcs ] [ Security ]
[ ]
[ ]
[ ]
[ ]
Class: ezcAuthentication
|
Container for authentication filters. [
source]
This is the main class of the authentication component. Filters are added to an object of this class, which will run the filters in sequence. At the end of this process, the status property will contain the statuses of the filters, and the developer can use those statuses to display to the user messages such as "Password incorrect".
The session property is optional and it is used to store the authentication information between requests.
The credentials property will be passed to all the filters in the queue.
Example (using the Htpasswd filter):
1. $credentials = new ezcAuthenticationPasswordCredentials( 'jan.modaal', 'b1b3773a05c0ed0176787a4f1574ff0075f7521e' );
2. $authentication = new ezcAuthentication( $credentials );
3. $authentication->session = new ezcAuthenticationSession();
4. $authentication->addFilter( new ezcAuthenticationHtpasswdFilter( '/etc/htpasswd' ) );
5. // add other filters if needed
6. if ( !$authentication->run() )
7. {
8. // authentication did not succeed, so inform the user
9. $status = $authentication->getStatus();
10. $err = array(
11. 'ezcAuthenticationHtpasswdFilter' => array(
12. ezcAuthenticationHtpasswdFilter::STATUS_USERNAME_INCORRECT => 'Incorrect username',
13. ezcAuthenticationHtpasswdFilter::STATUS_PASSWORD_INCORRECT => 'Incorrect password'
14. )
15. );
16. foreach ( $status as $line )
17. {
18. list( $key, $value ) = each( $line );
19. echo $err[$key][$value] . "\n";
20. }
21. }
22. else
23. {
24. // authentication succeeded, so allow the user to see his content
25. }
Properties
Member Variables
Method Summary
|
public ezcAuthentication |
__construct(
$credentials, [$options = null] )
Creates a new object of this class. |
|
public void |
addFilter(
$filter, [$stop = false] )
Adds an authentication filter at the end of the filter list. |
|
public ezcAuthenticationOptions |
getOptions(
)
Returns the options of this class. |
|
public array(string=>mixed) |
getStatus(
)
Returns the status of authentication. |
|
public bool |
run(
)
Runs through all the filters in the filter list. |
|
public void |
setOptions(
$options )
Sets the options of this class to $options. |
Methods
__construct
Creates a new object of this class.
Parameters
addFilter
Adds an authentication filter at the end of the filter list.
By specifying the second parameter as true, the authentication process (triggered by calling the run() method) will stop after processing this filter regardless of its success.
Parameters
| Name |
Type |
Description |
$filter |
ezcAuthenticationFilter |
The authentication filter to add |
$stop |
bool |
If authentication should continue past this filter |
getOptions
Returns the options of this class.
getStatus
array(string=>mixed) getStatus(
)
Returns the status of authentication.
The format of the returned array is array( array( class => code ) ).
run
bool run(
)
Runs through all the filters in the filter list.
setOptions
Sets the options of this class to $options.
Parameters
Last updated: Mon, 21 Dec 2009