-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
http basic authentication broken with PHP as cgi/fastCGI under Apache #1813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What about using the See: #1510 |
@fabpot, should we maybe add some extra abstraction for this to the Request class? |
+1, the request should definitly abstract this. |
The following works as a temporary workaround: app_dev.php:
web/.htaccess
|
It works fine for me with FastCGI and Nginx. Can you paste the whole output of |
Here is the output of $_SERVER without the workaround:
|
Finally I've made a working patch for that, I'll submit it as soon as I figure out how to submit a patch... ;) |
Task for the BHD: update the associated PR #3551 (there are some comments there) |
working on this issue today... |
has a working PR, just needs review: #3551 |
…fastCGI under Apache Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: symfony#1813 Todo: - In order to work, add this to the .htaccess: RewriteEngine on RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ app.php [QSA,L]
Commits ------- a450d00 [HttpFoundation] HTTP Basic authentication is broken with PHP as cgi/fastCGI under Apache Discussion ---------- [HttpFoundation] HTTP Basic authentication is broken with php-cgi under Apache Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: #1813 Todo: - In order to work, add this to the .htaccess: RewriteEngine on RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ app.php [QSA,L] --------------------------------------------------------------------------- by stof at 2012-03-10T17:34:26Z you should also add a unit test for this --------------------------------------------------------------------------- by kepten at 2012-03-11T15:34:04Z Thanks for the feedback, I committed the changes. --------------------------------------------------------------------------- by stof at 2012-04-04T01:59:53Z @fabpot could you review it ? --------------------------------------------------------------------------- by fabpot at 2012-04-04T07:15:34Z My comments: * `ServerBag` represents what we have in the `$_SERVER` global variables. As such, the code should be moved to the `getHeaders()` method instead like the other tweaks we do for the HTTP headers. * A comment must be added explaining why this is needed and the configuration the user must have to make it work (then remove the Github URLs). * The code should only be executed when `PHP_AUTH_USER` is not available (to not have any overhead when not needed). --------------------------------------------------------------------------- by danielholmes at 2012-04-14T13:27:09Z A quick note on that .htaccess/apache configuration required, if adding to the Symfony SE htaccess file, then it will need to look like this: ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ app.php [QSA,L] </IfModule> ``` NOTE: No **,L** in the Authorization Rewrite as in the original example - it prevents the front controller rewrite from happening --------------------------------------------------------------------------- by towards at 2012-04-20T16:12:49Z @kepten you were faster than me applying @fabpot's comments :) nevertheless part of the bug hunt day I also modified the ServerBag class and tested them on a productive LAMP hosting server using Apache and FastCGI --------------------------------------------------------------------------- by kepten at 2012-04-20T16:15:57Z ok, so is my PR is useless or should I still fix problems? --------------------------------------------------------------------------- by towards at 2012-04-20T16:20:26Z your PR is fine for sure and I don't want to interfere, just wanted to mention that part of the bug hunt day of Symfony I had a go at this PR as an "exercise" but just saw later on that you already fixed the problem, so you can ignore my pushes --------------------------------------------------------------------------- by vicb at 2012-04-20T16:20:36Z I have been working with @towards: your PR is useful, please implement his comments and squash your PR. --------------------------------------------------------------------------- by kepten at 2012-04-20T16:59:07Z never squashed before, is it okay now? :) --------------------------------------------------------------------------- by stof at 2012-04-20T17:21:07Z it is --------------------------------------------------------------------------- by vicb at 2012-05-20T19:57:51Z @fabpot this should be ready to be merged
Commits ------- 5d88255 Authorization header should only be rebuild when Basic Auth scheme is used Discussion ---------- [Regression fix] Authorization header should only be rebuild when Basic Auth scheme is used Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: fixes regression introduced by #1813 Todo: N/A License of the code: MIT --------------------------------------------------------------------------- by travisbot at 2012-06-11T14:40:28Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1592604) (merged cf5ee26a into 27100ba). --------------------------------------------------------------------------- by mvrhov at 2012-06-12T06:13:01Z fixed --------------------------------------------------------------------------- by travisbot at 2012-06-12T06:14:55Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1598555) (merged 5d88255 into 27100ba).
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #8952). Discussion ---------- [HttpFoundation] Fixing broken http auth digest in some circumstances. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | can be refered in issue #1813 | License | MIT | Doc PR | n/a With some apache + php-fpm setup we need to set ```PHP_AUTH_DIGEST``` value if not already setted in GLOBAL vars. Added some unit tests too. Commits ------- 9fc994b [HttpFoundation] Fixing broken http auth digest in some circumstances (php-fpm + apache).
private $username = 'test';
|
PHP_AUTH_PW might be empty in case of Apache2 + FastCGI-PHP Setup. See symfony/symfony#1813
|
thanks for this post, bug fixes and comments - I got this workaround to work on non "symfony", managed to patched "thttpd" web server and "PHP Navigator" file manager with your workarounds. |
…bison) This PR was submitted for the master branch but it was merged into the 3.4 branch instead. Discussion ---------- Simpler example for Apache basic auth workaround Uses a simpler regex and existing back-reference instead of reading header twice. | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | #1813 | License | MIT Improvement to code documentation, no change to executed code. Commits ------- 388528d Simpler example for Apache basic auth workaround
The keys PHP_AUTH_USER and PHP_AUTH_PW are not present in the superglobal $_SERVER, so http basic authentication needs to be handled a little differently.
This also affects functional tests which require http basic auth to authenticate.
Basically the workaround is two parts:
A rewrite rule to pack the username and password into an environment variable:
RewriteEngine on RewriteRule .\* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]Extract the info from the environment variable:
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':' , base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
See below for more details.
http://orangejuiceliberationfront.com/http-auth-with-php-in-cgi-mode-e-g-on-dreamhost/
http://www.besthostratings.com/articles/http-auth-php-cgi.html
The text was updated successfully, but these errors were encountered: