diff --git a/src/Pecee/Http/Request.php b/src/Pecee/Http/Request.php index 40b767c4..dd2ebc3d 100644 --- a/src/Pecee/Http/Request.php +++ b/src/Pecee/Http/Request.php @@ -39,8 +39,15 @@ public function getMethod() { * @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; } } \ No newline at end of file diff --git a/src/Pecee/Http/Response.php b/src/Pecee/Http/Response.php index 5d1a0c3e..5512b0ca 100644 --- a/src/Pecee/Http/Response.php +++ b/src/Pecee/Http/Response.php @@ -29,4 +29,9 @@ public function refresh() { $this->redirect(url()); } + public function auth($name = '') { + header('WWW-Authenticate: Basic realm="' . $name . '"'); + header('HTTP/1.0 401 Unauthorized'); + } + } \ No newline at end of file