mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: Make sure Request class can be dependency injected to fix SameSiteCookieMiddleware injection
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
5d65f14e60
commit
bbe766b07a
2 changed files with 7 additions and 12 deletions
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue