[FEATURE] Minor features

- Added basic auth to Response class.
- Added getPassword() method for basic auth password in Response class.
This commit is contained in:
Simon Sessingø
2015-10-21 15:09:32 +02:00
parent 58e4eb85bb
commit 8959a237f9
2 changed files with 14 additions and 2 deletions
+9 -2
View File
@@ -39,8 +39,15 @@ class Request {
* @return string|null
*/
public function getUser() {
$data = http_digest_parse($_SERVER['PHP_AUTH_DIGEST']);
return (isset($data['username'])) ? $data['username'] : null;
return (isset($_SERVER['PHP_AUTH_USER'])) ? $_SERVER['PHP_AUTH_USER']: null;
}
/**
* Get http basic auth password
* @return string|null
*/
public function getPassword() {
return (isset($_SERVER['PHP_AUTH_PW'])) ? $_SERVER['PHP_AUTH_PW']: null;
}
}
+5
View File
@@ -29,4 +29,9 @@ class Response {
$this->redirect(url());
}
public function auth($name = '') {
header('WWW-Authenticate: Basic realm="' . $name . '"');
header('HTTP/1.0 401 Unauthorized');
}
}