I am building a web service with Zend and i have to authenticate the users before sending them response. The user will send a request to a server page, using curl, passing his credentials in the form of curl_setopt($curl, CURLOPT_USERPWD, 'key:pass');

Now what i want is that, i must be able to retrieve the username and password at the server side (in my zend controller), so that i can verify the user credentials from database and send the response accordingly. So how can i do authentication in another page?

but, for the second case, as i said in the below comment, iam not getting those variables in the $_SERVER array. They appear only if the target page is a php file, which exists in the root directory.
–
shasi kanthFeb 10 '11 at 13:32

1

@dskanth depending on what authentication negotiated, you might have Digest authentication. See the second example in the PHP Manual and verify whether you have PHP_AUTH_DIGEST set
–
Gordon♦Feb 10 '11 at 13:57

Oh... yes, i have PHP_AUTH_DIGEST set, how can i modify this example to validate the credentials at the server side?
–
shasi kanthFeb 10 '11 at 14:39

@dskanth the example already does what you are asking for. I suggest you either read up on the used functions in the example or use the Zend_Auth component.
–
Gordon♦Feb 10 '11 at 15:03

Iam able to get those values only if i give the target file as .php, which is located inside the root directory. But iam using zend and the target file is a controller file with an action, that takes a parameter. I have edited the question with more information.
–
shasi kanthFeb 10 '11 at 12:58

Iam also able to get those values in $_SERVER array, if iam not using zend framework, and specify my curl url something like: localhost/pt1/public/api/v1/target.php, which is not part of zend application, and which is just a folder hierarchy. But how do i do it with zend controller and action?
–
shasi kanthFeb 10 '11 at 13:56