Skip to content

Commit e21b7d1

Browse files
CarlSchwansusnux
authored andcommitted
feat: Add generate session token to CsrfTokenManager
Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent c5c3525 commit e21b7d1

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function beforeController($controller, $methodName) {
196196
}
197197
}
198198
// CSRF check - also registers the CSRF token since the session may be closed later
199-
Server::get(CsrfTokenManager::class)->getToken()->getEncryptedValue();
199+
Server::get(CsrfTokenManager::class)->generateSessionToken();
200200
if ($this->isInvalidCSRFRequired($reflectionMethod)) {
201201
/*
202202
* Only allow the CSRF check to fail on OCS Requests. This kind of

lib/private/Security/CSRF/CsrfTokenManager.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,8 @@ public function isTokenValid(CsrfToken $token): bool {
7474
$token->getDecryptedValue()
7575
);
7676
}
77+
78+
public function generateSessionToken(): void {
79+
$this->getToken();
80+
}
7781
}

lib/public/Util.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ public static function sanitizeHTML(string|array|null $value): string|array {
449449
return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
450450
}, $value);
451451
}
452-
// Specify encoding for PHP<5.4
453452
return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
454453
}
455454

0 commit comments

Comments
 (0)