03.02.2014 Views

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

HTTP ” 21<br />

Digest HTTP Authentication<br />

Digest authentication is a bit more involved. The WWW-Authenticate header returned<br />

by the server will contain the word “Digest” follo wed by a single space and then by a<br />

number of key -value pairs in the format key=“value” separated by commas. Belo w is<br />

an example of this header.<br />

WWW-Authenticate: Digest realm="testrealm@host.com",<br />

qop="auth,auth-int",<br />

nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",<br />

opaque="5ccc069c403ebaf9f0171e9517f40e41"<br />

The client must respond <strong>with</strong> a specific response value that the server will verify before<br />

it allo ws the client <strong>to</strong> proceed. To derive that value requires use of the MD5 hash<br />

algorithm, which in <strong>PHP</strong> can be accessed using the md5 or hash functions. H ere is the<br />

process.<br />

• Concatenate the appropriate username, the value of the realm key pro vided<br />

by the server, and the appropriate password <strong>to</strong>gether separated by colons and<br />

take the MD5 hash of that string. W e’ll call this HA1. It shouldn’t change for<br />

the rest of the session.<br />

<br />

• Concatenate the method and URI of the original request separated by a colon<br />

and take the MD5 hash of that string. W e’ll call this HA2. This will ob viously<br />

vary <strong>with</strong> your method or URI.<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!