Documentation

Digest Authentication - Zend_Auth

Digest Authentication

Introduction

» Digest authentication is a method of HTTP authentication that improves upon » Basic authentication by providing a way to authenticate without having to transmit the password in clear text across the network.

This adapter allows authentication against text files containing lines having the basic elements of Digest authentication:

  • username, such as "joe.user"

  • realm, such as "Administrative Area"

  • MD5 hash of the username, realm, and password, separated by colons

The above elements are separated by colons, as in the following example (in which the password is "somePassword"):

  1. someUser:Some Realm:fde17b91c3a510ecbaf7dbd37f59d4f8

Specifics

The digest authentication adapter, Zend_Auth_Adapter_Digest, requires several input parameters:

  • filename - Filename against which authentication queries are performed

  • realm - Digest authentication realm

  • username - Digest authentication user

  • password - Password for the user of the realm

These parameters must be set prior to calling authenticate().

Identity

The digest authentication adapter returns a Zend_Auth_Result object, which has been populated with the identity as an array having keys of realm and username. The respective array values associated with these keys correspond to the values set before authenticate() is called.

  1. $adapter = new Zend_Auth_Adapter_Digest($filename,
  2.                                         $realm,
  3.                                         $username,
  4.                                         $password);
  5.  
  6. $result = $adapter->authenticate();
  7.  
  8. $identity = $result->getIdentity();
  9.  
  10. print_r($identity);
  11.  
  12. /*
  13. Array
  14. (
  15.     [realm] => Some Realm
  16.     [username] => someUser
  17. )
  18. */

Copyright

© 2006-2021 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts