Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Common/CsrfCounterMeasure.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use ipl\Html\Contract\FormElement;
use ipl\Html\FormElement\HiddenElement;

trait CsrfCounterMeasure

Check failure on line 9 in src/Common/CsrfCounterMeasure.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Trait ipl\Web\Common\CsrfCounterMeasure is used zero times and is not analysed.

Check failure on line 9 in src/Common/CsrfCounterMeasure.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Trait ipl\Web\Common\CsrfCounterMeasure is used zero times and is not analysed.

Check failure on line 9 in src/Common/CsrfCounterMeasure.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Trait ipl\Web\Common\CsrfCounterMeasure is used zero times and is not analysed.
{
/**
* Create a form element to countermeasure CSRF attacks
Expand All @@ -26,6 +26,12 @@
'ignore' => true,
'required' => true,
'validators' => ['Callback' => function ($token) use ($uniqueId, $hashAlgo) {
switch ($_SERVER['HTTP_SEC_FETCH_SITE'] ?? '') {
case 'same-origin': // same scheme, host and port
case 'none': // a user-originated operation
return true;
}

if (empty($token) || strpos($token, '|') === false) {
throw new Error('Invalid CSRF token provided');
}
Expand Down
Loading