启用Apache http授权标头 [英] enable Apache http Authorization header

查看:591
本文介绍了启用Apache http授权标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 PHP ZF2 写一个 API 他们使用 HTTP 授权。我使用 apache_request_headers()获取所有 HTTP 标题(也使用ZF2的 $ this->测试; getRequest() - > getHeaders())

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()).

它适用于我的语言环境安装版本。但是在我的服务器上,HTTP授权标头不可用。我的浏览器调试工具向我显示授权标头正确发送。

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.

两台服务器都使用相同的软件运行: Ubuntu 14.04 使用 Apache2 (服务器版本: Apache / 2.4.7 (Ubuntu))。

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

已启用 apache2 模块( auth_basic 已启用):

Enabled apache2 modules (auth_basic is enabled):

是否有 PHP ini 设置允许授权标题?

Is there a PHP ini setting to allow Authorization header?

编辑2015-05-13:

edit 2015-05-13:

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

在我的语言环境系统上,这将在服务器上返回你是auth没有授权'。在Chrome浏览器中使用Postman应用程序进行测试。

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

编辑2015-05-14:
我认为这是Apache2主题。

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

如何在Apache2中启用Authorization标头?

How can i enable the Authorization header in Apache2?

推荐答案

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

解决了这个问题。

但我不知道为什么在我的语言环境系统中没有必要这样做。

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

这篇关于启用Apache http授权标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆