Always getting "401 Unauthorized" - Apache 2.4.29 and PHP 7.2
seth100 opened this issue · 3 comments
seth100 commented
Hi,
I'm using v2.3.0
(to maintain compatibility with my remote hosting server where I have PHP 7.0).
I have created a Docker container (webdevops/php-apache:ubuntu-18.04) for a fast PHP / Apache2 system where I can test my REST interface.
There I have:
Ubuntu 18.04
- PHP
7.2.7-0ubuntu0.18.04.2
- Apache
2.4.29
Here is my code:
$this->slimObj = new \Slim\App();
$this->slimObj->get("/test", function($request, $response, $arguments) {
print "test";
});
$this->slimObj->add(new \Slim\Middleware\HttpBasicAuthentication([
"path" => "/",
"secure" => false,
"users" => [
"root" => "password"
]
]));
Call:
curl localhost:9080/server/test.php/test --user root:password --include
Response:
HTTP/1.1 401 Unauthorized
Date: Sun, 12 Aug 2018 12:56:47 GMT
Server: Apache/2.4.29 (Ubuntu)
WWW-Authenticate: Basic realm="Protected"
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Made many attempts, no luck!
Any help please?
Also tried with new v3.0, same issue.
seth100 commented
Also, my phpinfo()
says:
Server API FPM/FastCGI
don't know whether it is a useful info!
seth100 commented
Added
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
to .htaccess
and problem solved :).
tuupola commented
Great :)