enable Apache http Authorization header

三世轮回 提交于 2019-12-23 17:39:16

问题


I write an API with PHP ZF2 they use HTTP Authorization. I fetch all HTTP Headers with apache_request_headers() (also tested with ZF2's $this->getRequest()->getHeaders()).

It works on my locale installed version. But on my server the HTTP Authorization Header are not available. My Browser Debug tool show me that the Authorization header properly send.

Both server are running with the same software: Ubuntu 14.04 with Apache2 (Server version: Apache/2.4.7 (Ubuntu)).

Enabled apache2 modules (auth_basic is enabled):

Is there a PHP ini setting to allow Authorization header?

edit 2015-05-13:

$headers = apache_request_headers();
if (isset($headers['Authorization'])) {
    echo 'you are auth';
} else {
    echo 'there is no Authorization';
}

On my locale system this returns 'you are auth', on the server 'there is no Authorization'. Tested with Postman app in Chrome browser.

edit 2015-05-14: I think it is an Apache2 topic.

How can i enable the Authorization header in Apache2?


回答1:


SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

in the .htaccess solves the problem.

But i do not know why this is not necessary on my locale system.



来源:https://stackoverflow.com/questions/37158714/enable-apache-http-authorization-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!