alcalyn / authorization-header-fix
Simple listener that restore Authorization header in a Symfony Request under Apache.
Installs: 1 682
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.3
This package is not auto-updated.
Last update: 2024-12-11 21:03:41 UTC
README
Using a Symfony application on Apache, you get null
when trying to get Authorization header with $request->headers->get('Authorization');
.
The why is explained in this Stackoverflow question.
So if you don't want to patch your .htaccess, this library, inspired by fschmengler's answer in this another SO question, provides a listener which adds the Authorization header to a Symfony Request instance.
Installation
Download
Using Composer:
{ "require": { "alcalyn/authorization-header-fix": "1.0.x" } }
Register listener
To fix all Requests in a full stack Symfony app, register a listener like this:
# app/config/services.yml services: acme.listeners.authorization_header_fix: class: Alcalyn\AuthorizationHeaderFix\AuthorizationHeaderFixListener tags: - { name: kernel.event_listener, event: kernel.request, priority: 10 }
Or using Silex:
$this->on('kernel.request', array( new Alcalyn\AuthorizationHeaderFix\AuthorizationHeaderFixListener(), 'onKernelRequest' ), 10);
Note:
An higher priority is recommended to have the Authorization header available in others listeners.
License
This library is under MIT License.