Skip to content

Commit e0f758f

Browse files
authored
Merge pull request #5665 from kenjis/fix-security-redirect
fix: Config CSRF $redirect does not work
2 parents 9712791 + 2318446 commit e0f758f

File tree

4 files changed

+9
-57
lines changed

4 files changed

+9
-57
lines changed

app/Config/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ class App extends BaseConfig
436436
* Defaults to `Lax` as recommended in this link:
437437
*
438438
* @see https://portswigger.net/web-security/csrf/samesite-cookies
439-
* @deprecated Use `Config\Security` $samesite property instead of using this property.
439+
* @deprecated `Config\Cookie` $samesite property is used.
440440
*
441441
* @var string
442442
*/

app/Config/Security.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class Security extends BaseConfig
111111
*
112112
* @var string
113113
*
114-
* @deprecated
114+
* @deprecated `Config\Cookie` $samesite property is used.
115115
*/
116116
public $samesite = 'Lax';
117117
}

phpstan-baseline.neon.dist

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -741,63 +741,13 @@ parameters:
741741
path: system/Router/Router.php
742742

743743
-
744-
message: "#^Property Config\\\\App\\:\\:\\$CSRFCookieName \\(string\\) on left side of \\?\\? is not nullable\\.$#"
745-
count: 1
746-
path: system/Security/Security.php
747-
748-
-
749-
message: "#^Property Config\\\\App\\:\\:\\$CSRFExpire \\(int\\) on left side of \\?\\? is not nullable\\.$#"
750-
count: 1
751-
path: system/Security/Security.php
752-
753-
-
754-
message: "#^Property Config\\\\App\\:\\:\\$CSRFHeaderName \\(string\\) on left side of \\?\\? is not nullable\\.$#"
755-
count: 1
756-
path: system/Security/Security.php
757-
758-
-
759-
message: "#^Property Config\\\\App\\:\\:\\$CSRFRegenerate \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
760-
count: 1
761-
path: system/Security/Security.php
762-
763-
-
764-
message: "#^Property Config\\\\App\\:\\:\\$CSRFTokenName \\(string\\) on left side of \\?\\? is not nullable\\.$#"
765-
count: 1
766-
path: system/Security/Security.php
767-
768-
-
769-
message: "#^Property Config\\\\Security\\:\\:\\$cookieName \\(string\\) on left side of \\?\\? is not nullable\\.$#"
770-
count: 1
744+
message: "#^Property Config\\\\App\\:\\:\\$CSRF[a-zA-Z]+ \\([a-zA-Z]+\\) on left side of \\?\\? is not nullable\\.$#"
745+
count: 6
771746
path: system/Security/Security.php
772747

773748
-
774-
message: "#^Property Config\\\\Security\\:\\:\\$csrfProtection \\(string\\) on left side of \\?\\? is not nullable\\.$#"
775-
count: 1
776-
path: system/Security/Security.php
777-
778-
-
779-
message: "#^Property Config\\\\Security\\:\\:\\$expires \\(int\\) on left side of \\?\\? is not nullable\\.$#"
780-
count: 1
781-
path: system/Security/Security.php
782-
783-
-
784-
message: "#^Property Config\\\\Security\\:\\:\\$headerName \\(string\\) on left side of \\?\\? is not nullable\\.$#"
785-
count: 1
786-
path: system/Security/Security.php
787-
788-
-
789-
message: "#^Property Config\\\\Security\\:\\:\\$regenerate \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
790-
count: 1
791-
path: system/Security/Security.php
792-
793-
-
794-
message: "#^Property Config\\\\Security\\:\\:\\$tokenName \\(string\\) on left side of \\?\\? is not nullable\\.$#"
795-
count: 1
796-
path: system/Security/Security.php
797-
798-
-
799-
message: "#^Property Config\\\\Security\\:\\:\\$tokenRandomize \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
800-
count: 1
749+
message: "#^Property Config\\\\Security\\:\\:\\$[a-zA-Z]+ \\([a-zA-Z]+\\) on left side of \\?\\? is not nullable\\.$#"
750+
count: 8
801751
path: system/Security/Security.php
802752

803753
-

system/Security/Security.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class Security implements SecurityInterface
136136
*
137137
* @var string
138138
*
139-
* @deprecated
139+
* @deprecated `Config\Cookie` $samesite property is used.
140140
*/
141141
protected $samesite = Cookie::SAMESITE_LAX;
142142

@@ -169,6 +169,7 @@ public function __construct(App $config)
169169
$this->tokenName = $security->tokenName ?? $this->tokenName;
170170
$this->headerName = $security->headerName ?? $this->headerName;
171171
$this->regenerate = $security->regenerate ?? $this->regenerate;
172+
$this->redirect = $security->redirect ?? $this->redirect;
172173
$this->rawCookieName = $security->cookieName ?? $this->rawCookieName;
173174
$this->expires = $security->expires ?? $this->expires;
174175
$this->tokenRandomize = $security->tokenRandomize ?? $this->tokenRandomize;
@@ -179,6 +180,7 @@ public function __construct(App $config)
179180
$this->regenerate = $config->CSRFRegenerate ?? $this->regenerate;
180181
$this->rawCookieName = $config->CSRFCookieName ?? $this->rawCookieName;
181182
$this->expires = $config->CSRFExpire ?? $this->expires;
183+
$this->redirect = $config->CSRFRedirect ?? $this->redirect;
182184
}
183185

184186
if ($this->isCSRFCookie()) {

0 commit comments

Comments
 (0)