Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request headers bag is missing Authorization header in Symfony 2?

I'm trying to implement a custom authentication provider in Symfony 2. I'm sending a test request using Fiddler and printing all headers server side; well, Authorization header is missing.

Am i doing something wrong?

GET /RESTfulBackend/web/index.php HTTP/1.1 Authorization: FID 44CF9590006BF252F707:jZNOcbfWmD/ Host: localhost User-Agent: Fiddler Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3 

Listener just prints the headers and quits:

class HMACListener implements ListenerInterface {     private $securityContext;      private $authenticationManager;      public function handle(GetResponseEvent $event)     {         $request = $event->getRequest();         print_r($request->headers->all());          die();      } } 

Response is missing Authorization header:

Array (     [host] => Array         (             [0] => localhost         )     [user-agent] => Array         (             [0] => Fiddler         )     [accept] => Array         (             [0] => text/html,application/xhtml+xml,application/xml         )     [accept-language] => Array         (             [0] => it-it,it;q=0.8,en-us;q=0.5,en;q=0.3         ) ) 
like image 486
Polmonino Avatar asked Aug 16 '12 15:08

Polmonino


1 Answers

You must add this code to a virtualhost tag

It will not work if you put it in a Directory tag.

    RewriteEngine On     RewriteCond %{HTTP:Authorization} ^(.*)     RewriteRule .* - [e=HTTP_AUTHORIZATION:%1] 
like image 98
Akambi Fagbohoun Avatar answered Sep 29 '22 13:09

Akambi Fagbohoun