Authentication: ezcAuthenticationHtpasswdFilter
[ ]
[ Rfcs ] [ Security ]
[ ]
[ ]
[ ]
[ ]
Class: ezcAuthenticationHtpasswdFilter
|
Filter to authenticate against an Unix htpasswd file. [
source]
It supports files created with the htpasswd command options -m (MD5 encryption - different than the PHP md5() function) -d (CRYPT encryption) -s (SHA encryption) -p (plain text)
The encryption used for the password field in the file will be detected automatically.
The password property can be specified as plain text or in encrypted form, depending on the option 'plain' in the ezcAuthenticationHtpasswdOptions object used as options.
Example:
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. }
Parents
ezcAuthenticationFilter
|
--ezcAuthenticationHtpasswdFilter
Constants
Inherited Constants
From
ezcAuthenticationFilter:
Properties
|
string |
read/write
|
$file
The path and file name of the htpasswd file to use. |
Inherited Member Variables
From
ezcAuthenticationFilter:
Method Summary
|
public ezcAuthenticationHtpasswdFilter |
__construct(
$file, [$options = null] )
Creates a new object of this class. |
|
public int |
run(
$credentials )
Runs the filter and returns a status code when finished. |
Inherited Methods
From
ezcAuthenticationFilter :
Methods
__construct
Creates a new object of this class.
Parameters
Throws
| Class | Description |
ezcBaseValueException |
if the value provided is not correct for the property $file |
ezcBaseFileNotFoundException |
if $file does not exist |
ezcBaseFilePermissionException |
if $file cannot be opened for reading |
run
Runs the filter and returns a status code when finished.
Parameters
Redefinition of
Last updated: Mon, 27 Jul 2009