lithium\net\http\Auth::header()
Returns the proper header string. Accepts the data from the encode
method.
Parameters
-
array
$data
Returns
stringSource
public static function header($data) {
if (empty($data['response'])) {
return null;
}
if (isset($data['nonce'])) {
$defaults = [
'realm' => 'app', 'method' => 'GET', 'uri' => '/',
'username' => null, 'qop' => 'auth',
'nonce' => null, 'opaque' => null,
'cnonce' => md5(time()), 'nc' => static::$nc
];
$data += $defaults;
$auth = "username=\"{$data['username']}\", response=\"{$data['response']}\", ";
$auth .= "uri=\"{$data['uri']}\", realm=\"{$data['realm']}\", ";
$auth .= "qop=\"{$data['qop']}\", nc={$data['nc']}, cnonce=\"{$data['cnonce']}\", ";
$auth .= "nonce=\"{$data['nonce']}\", opaque=\"{$data['opaque']}\"";
return "Digest " . $auth;
}
return "Basic " . $data['response'];
}