Prev | Current Page 176 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

com>
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
Figure 6.2: HTTP Authentication showing Zend_Auth methods.
To implement this, firstly, we need to configure the Zend_Auth_Adapater_Http as shown in listing 6.1.
Listing 6.1 Configuration of Zend_Auth_Adapter_Http
// create a Zend_Auth_Adapter_Http instance
$config['accept_schemes'] = 'basic';
$config['realm'] = 'ZFiA Chapter 06';
$authAdapter = new Zend_Auth_Adapter_Http($config); #1
$resolver = new Zend_Auth_Adapter_Http_Resolver_File('passwords.txt');
$authAdapter->setBasicResolver($resolver);
$authAdapter->setRequest($request); |#2
$authAdapter->setResponse($response); |
(annotation) <#1 Create the adapter>
(annotation) <#2 Access to http headers>
As you can see, configuration of a Zend_Auth_Adapter_Http object is two stage as some settings are
configured within the $config array that is used on construction of the object (#1), and the setting of the
resolver, request and response objects is done after creation. The request object is used to retrieve the username
and password and the response object is used to set the correct HTTP headers to indicate if authentication was
successful (or not).
Licensed to Menshu You

Pages:
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
www.buciki.edu.pl mobilna suwnica hydrauliczna Poznań hotele praga Okna PCV Wrocław Pozycjonowanie Wrocław