@@ 198-207 (lines=10) @@ | ||
195 | // Grab the user that corresponds to that "username" |
|
196 | // exact field determined in the api config file - api.auth_field setting. |
|
197 | $user = $this->user_model->as_array()->find_by( config_item('api.auth_field'), $digest['username'] ); |
|
198 | if (! $user) |
|
199 | { |
|
200 | $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
201 | // If an email is used, log the attempt |
|
202 | if (config_item('api.auth_field') === 'email') |
|
203 | { |
|
204 | $this->ci->login_model->recordLoginAttempt($digest['username']); |
|
205 | } |
|
206 | return false; |
|
207 | } |
|
208 | ||
209 | // Calc the correct response |
|
210 | $A1 = $user['digest_key']; |
|
@@ 221-230 (lines=10) @@ | ||
218 | } |
|
219 | $valid_response = md5($A1 .':'. $digest['nonce'].':'. $digest['nc'] .':'. $digest['cnonce'] .':'. $digest['qop'] .':'. $A2); |
|
220 | ||
221 | if ($digest['response'] != $valid_response) |
|
222 | { |
|
223 | $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
224 | // If an email is used, log the attempt |
|
225 | if (config_item('api.auth_field') === 'email') |
|
226 | { |
|
227 | $this->ci->login_model->recordLoginAttempt($digest['username']); |
|
228 | } |
|
229 | return false; |
|
230 | } |
|
231 | ||
232 | $this->user = $user; |
|
233 |