Skip to content

Commit

Permalink
Use "X-Csrf-Token" as seen @ https://en.wikipedia.org/wiki/Cross-site…
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 29, 2023
1 parent b398de7 commit 6836649
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/php/web/frontend/Frontend.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function view($req, $res, $delegate, $matches= []) {
}

// Verify CSRF token for anything which is not a GET or HEAD request
$token= $req->param('token') ?? $req->header('X-CSRF-Token');
$token= $req->param('token') ?? $req->header('X-Csrf-Token');
if (!isset($CSRF_EXEMPT[strtolower($req->method())]) && $req->value('token') !== $token) {
return $this->errors()->handle(new Error(403, 'Incorrect CSRF token for '.$delegate->name()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/web/frontend/unittest/CSRFTokenTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function validated_as_part_of_payload() {

#[Test]
public function validated_as_header() {
$this->execute('POST', '/users', 'username=test', ['X-CSRF-Token' => self::TOKEN]);
$this->execute('POST', '/users', 'username=test', ['X-Csrf-Token' => self::TOKEN]);
}

#[Test]
Expand Down

0 comments on commit 6836649

Please sign in to comment.