Skip to content

Commit 9a5da9c

Browse files
realmerxmrts
authored andcommitted
Fixed http header names to be treated as case-insensitive
(cherry picked from commit a5f813c)
1 parent 48bb282 commit 9a5da9c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/src/Auth.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ private function getPrincipalNameFromCertificate(X509 $userCertificate): string
9797
*/
9898
public function validate()
9999
{
100-
$headers = getallheaders();
101-
if (!isset($headers["X-CSRF-TOKEN"]) || ($headers["X-CSRF-TOKEN"] != $_SESSION["csrf-token"])) {
100+
// Header names must be treated as case-insensitive (according to RFC2616) so we convert them to lowercase
101+
$headers = array_change_key_case(getallheaders(), CASE_LOWER);
102+
103+
if (!isset($headers["x-csrf-token"]) || ($headers["x-csrf-token"] != $_SESSION["csrf-token"])) {
102104
header("HTTP/1.0 405 Method Not Allowed");
103105
echo "CSRF token missing, unable to process your request";
104106
return;

0 commit comments

Comments
 (0)