Skip to content

Commit c669ab0

Browse files
dstillmanuniuuu
authored andcommitted
Allow lowercase Authorization header
Other headers were accepted as lowercase (including Zotero-API-Key), but not Authorization Fixes #27
1 parent 28a234e commit c669ab0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

controllers/ApiController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,13 @@ public function init($extra) {
212212
// other than Basic/Digest, so use an Apache-specific method to get the header
213213
if (!$key && function_exists('apache_request_headers')) {
214214
$headers = apache_request_headers();
215-
if (isset($headers['Authorization'])) {
215+
if (isset($headers['Authorization']) || isset($headers['authorization'])) {
216+
$val = isset($headers['Authorization'])
217+
? $headers['Authorization']
218+
: $headers['authorization'];
216219
// Look for "Authorization: Bearer" from OAuth 2.0, and ignore everything else
217-
if (preg_match('/^bearer/i', $headers['Authorization'], $matches)) {
218-
if (preg_match('/^bearer +([a-z0-9]+)$/i', $headers['Authorization'], $matches)) {
220+
if (preg_match('/^bearer/i', $val, $matches)) {
221+
if (preg_match('/^bearer +([a-z0-9]+)$/i', $val, $matches)) {
219222
$key = $matches[1];
220223
}
221224
else {

0 commit comments

Comments
 (0)