5 class Http extends \Rsi\Fred\User\Authenticator{
12 if(!$this->controllerName){
14 ($data = $this->
digest()) &&
15 $this->
verify($data,$this->
component(
'event')->trigger(self::EVENT_PASSWORD,$this,$data[
'username']))
24 if($this->checked && !headers_sent()) http_response_code(401);
31 http_response_code(401);
32 header(
'WWW-Authenticate: Digest realm="' . $this->realm .
'",qop="auth",nonce="' . uniqid() .
'",opaque="' . $this->
hash([$this->realm]) .
'"');
40 if(array_key_exists(
'PHP_AUTH_DIGEST',$_SERVER))
foreach([
'nonce',
'nc',
'cnonce',
'qop',
'username',
'uri',
'response'] as $key)
41 if(preg_match(
'/' . $key .
'=(?:([\'"])([^\\1]+?)\\1|([^\\s,]+))/',$_SERVER[
'PHP_AUTH_DIGEST'],$match)) $data[$key] = $match[2] ?: $match[3];
46 protected function hash($data){
47 return md5(implode(
':',$data));
55 public function verify($data,$password){
57 $this->
hash([$data[
'username'],$this->realm,$password]),
58 $data[
'nonce'],$data[
'nc'],$data[
'cnonce'],$data[
'qop'],
59 $this->
hash([$_SERVER[
'REQUEST_METHOD'],$data[
'uri']])
61 if(!$this->checked && !headers_sent()) http_response_code(401);
62 return $this->checked;
verify($data, $password)
Verify a password.
digest()
Retrieve data from authentication digest.
prompt()
Send headers for the digest prompt.
verified($result)
Process the result of a verification.
component($name)
Get a component (local or default).