aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2025-06-19 11:41:43 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2025-07-08 13:32:14 +0200
commitbbe766b07a74d218a6140d29bcaa7322c9483f30 (patch)
treed23c6f0490cdc5a378498171995a37ed224299c2
parent5d65f14e608f5c3cdb8f8c212f4f49cada024a03 (diff)
downloadnextcloud-server-bbe766b07a74d218a6140d29bcaa7322c9483f30.tar.gz
nextcloud-server-bbe766b07a74d218a6140d29bcaa7322c9483f30.zip
fix: Make sure Request class can be dependency injected to fix SameSiteCookieMiddleware injection
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php16
-rw-r--r--lib/private/Server.php3
2 files changed, 7 insertions, 12 deletions
diff --git a/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php b/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php
index ed3bb232023..097ed1b2b8f 100644
--- a/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php
+++ b/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php
@@ -14,16 +14,10 @@ use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;
class SameSiteCookieMiddleware extends Middleware {
- /** @var Request */
- private $request;
-
- /** @var ControllerMethodReflector */
- private $reflector;
-
- public function __construct(Request $request,
- ControllerMethodReflector $reflector) {
- $this->request = $request;
- $this->reflector = $reflector;
+ public function __construct(
+ private Request $request,
+ private ControllerMethodReflector $reflector,
+ ) {
}
public function beforeController($controller, $methodName) {
@@ -59,7 +53,7 @@ class SameSiteCookieMiddleware extends Middleware {
throw $exception;
}
- protected function setSameSiteCookie() {
+ protected function setSameSiteCookie(): void {
$cookieParams = $this->request->getCookieParams();
$secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : '';
$policies = [
diff --git a/lib/private/Server.php b/lib/private/Server.php
index b6dbdf62bdc..4b88a446405 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -871,7 +871,7 @@ class Server extends ServerContainer implements IServerContainer {
$c->get(IMimeTypeDetector::class)
);
});
- $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
+ $this->registerService(Request::class, function (ContainerInterface $c) {
if (isset($this['urlParams'])) {
$urlParams = $this['urlParams'];
} else {
@@ -905,6 +905,7 @@ class Server extends ServerContainer implements IServerContainer {
$stream
);
});
+ $this->registerAlias(\OCP\IRequest::class, Request::class);
$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
return new RequestId(