Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-03-22 12:51:54 +0300
committerJoas Schilling <coding@schilljs.com>2022-03-23 12:47:56 +0300
commita0c7798c7dd0ec537a6ed3b964103a9ad94d2040 (patch)
tree9e68e05927644e5b382420ed5dabdbbd5688c569 /lib
parent0fa17f8902e7391f189227b406a0058af6c4a4e0 (diff)
Limit the length of app password names
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Authentication/Token/Manager.php4
-rw-r--r--lib/private/Authentication/Token/PublicKeyTokenProvider.php4
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/private/Authentication/Token/Manager.php b/lib/private/Authentication/Token/Manager.php
index 0a7a821e23e..ae0874733f8 100644
--- a/lib/private/Authentication/Token/Manager.php
+++ b/lib/private/Authentication/Token/Manager.php
@@ -61,6 +61,10 @@ class Manager implements IProvider {
string $name,
int $type = IToken::TEMPORARY_TOKEN,
int $remember = IToken::DO_NOT_REMEMBER): IToken {
+ if (mb_strlen($name) > 128) {
+ throw new InvalidTokenException('The given name is too long');
+ }
+
try {
return $this->publicKeyTokenProvider->generateToken(
$token,
diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
index d2ee47cf380..26337029d77 100644
--- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php
+++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
@@ -84,6 +84,10 @@ class PublicKeyTokenProvider implements IProvider {
string $name,
int $type = IToken::TEMPORARY_TOKEN,
int $remember = IToken::DO_NOT_REMEMBER): IToken {
+ if (mb_strlen($name) > 128) {
+ throw new InvalidTokenException('The given name is too long');
+ }
+
$dbToken = $this->newToken($token, $uid, $loginName, $password, $name, $type, $remember);
$this->mapper->insert($dbToken);