Skip to content

Commit e9359ac

Browse files
committed
removed samesite check using cookie (BC break)
1 parent 9e845f8 commit e9359ac

6 files changed

Lines changed: 1 addition & 83 deletions

File tree

src/Bridges/HttpDI/HttpExtension.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getConfigSchema(): Nette\Schema\Schema
3939
'cookiePath' => Expect::string()->dynamic(),
4040
'cookieDomain' => Expect::string()->dynamic(),
4141
'cookieSecure' => Expect::anyOf('auto', null, true, false)->firstIsDefault()->dynamic(), // Whether the cookie is available only through HTTPS
42-
'disableNetteCookie' => Expect::bool(false), // disables cookie use by Nette
42+
'disableNetteCookie' => Expect::bool(false)->deprecated(),
4343
]);
4444
}
4545

@@ -138,13 +138,6 @@ private function sendHeaders(): void
138138
$this->initialization->addBody('$response->setHeader(?, ?);', [$key, $value]);
139139
}
140140
}
141-
142-
if (!$config->disableNetteCookie) {
143-
$this->initialization->addBody(
144-
'Nette\Http\Helpers::initCookie($this->getService(?), $response);',
145-
[$this->prefix('request')],
146-
);
147-
}
148141
}
149142

150143

src/Http/Helpers.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ final class Helpers
1919
{
2020
use Nette\StaticClass;
2121

22-
/** @internal */
23-
public const StrictCookieName = '_nss';
24-
2522

2623
/**
2724
* Formats a date and time in the HTTP date format (RFC 7231), e.g. 'Mon, 23 Jan 1978 10:00:00 GMT'.
@@ -55,13 +52,4 @@ public static function ipMatch(string $ip, string $mask): bool
5552

5653
return strncmp($ip, $mask, $size === '' ? $max : (int) $size) === 0;
5754
}
58-
59-
60-
/**
61-
* Sends the strict same-site cookie used to detect same-site requests.
62-
*/
63-
public static function initCookie(IRequest $request, IResponse $response): void
64-
{
65-
$response->setCookie(self::StrictCookieName, '1', 0, '/', sameSite: IResponse::SameSiteStrict);
66-
}
6755
}

src/Http/IRequest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
/**
1212
* HTTP request contract providing access to URL, headers, cookies, uploaded files, and body.
1313
* @method ?UrlImmutable getReferer() Returns the referrer URL.
14-
* @method bool isSameSite() Checks whether the request is coming from the same site.
1514
* @method bool isFrom(string|list<string>|null $site = null, string|list<string>|null $initiator = null)
1615
*/
1716
interface IRequest

src/Http/Request.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,6 @@ public function isSecured(): bool
228228
}
229229

230230

231-
/** @deprecated use isFrom(['same-site', 'same-origin']) */
232-
public function isSameSite(): bool
233-
{
234-
return isset($this->cookies[Helpers::StrictCookieName]);
235-
}
236-
237-
238231
/**
239232
* Checks whether the request origin and initiator match the given Sec-Fetch-Site and Sec-Fetch-Dest values.
240233
* Falls back to the Origin header for browsers that don't send Sec-Fetch headers (Safari < 16.4).

tests/Http.DI/HttpExtension.sameSiteProtection.disabled.phpt

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/Http.DI/HttpExtension.sameSiteProtection.phpt

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)