|
@@ 163-167 (lines=5) @@
|
| 160 |
|
$opaque = md5(uniqid()); |
| 161 |
|
|
| 162 |
|
// No digest string? Then you're done. Go home. |
| 163 |
|
if (empty($digest_string)) |
| 164 |
|
{ |
| 165 |
|
$this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
| 166 |
|
return false; |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
// Grab the parts from the digest string. |
| 170 |
|
// They will be provided as an array of the parts: username, nonce, uri, nc, cnonce, qop, response |
|
@@ 175-179 (lines=5) @@
|
| 172 |
|
preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches); |
| 173 |
|
$digest = (empty($matches[1]) || empty($matches[2])) ? array() : array_combine($matches[1], $matches[2]); |
| 174 |
|
|
| 175 |
|
if (! array_key_exists('username', $digest)) |
| 176 |
|
{ |
| 177 |
|
$this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
| 178 |
|
return false; |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
// Grab the user that corresponds to that "username" |
| 182 |
|
// exact field determined in the api config file - api.auth_field setting. |