symfony: [HttpFoundation] Authorization header not available via headers()
I’m using Apache 2.4 and php 7.0 configured as module and HttpFoundation 3.0.9. I’ve read https://github.com/symfony/symfony-docs/pull/2529/files#r3886789 and added the RewriteRule although not running PHP through CGI.
When calling app with a Authorization: Bearer .... header, it’s not available via headers(). It is however visible via apache_request_headers().
Why isn’t Symfony picking up the apache header?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 23 (10 by maintainers)
In my case I had to add to virtual machine config in Apache:
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1After this HTTP_AUTHORIZATION appeared in $_SERVER (with value Bearer Xxxx). Now I can get it’s value from $request->headers->get(‘Authorization’)From the doc of LexikJwtAuthenticationBundle
https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/index.md
Shouldn’t this rather go somewhere here https://github.com/symfony/symfony/blob/9a90cde4ed72bb9226354ceeecc869ee9ebee493/src/Symfony/Component/HttpFoundation/ServerBag.php#L99?
adapted from https://stackoverflow.com/questions/40582161/how-to-properly-use-bearer-tokens
Got it.
ServerBagist responsible for undoing the PHP madness,createFromGlobalsis responsible for obtaining global data.