aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Security
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-04-05 12:50:08 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-04-05 12:50:08 +0200
commit426c0341ffff262f58d1b7f031de4f0c53c8bec5 (patch)
treeac61718627051e469d256685cbe1001b2448d926 /lib/private/Security
parent5063b76c8ac41199c0a0cc088224d4ab0c1ae9b3 (diff)
downloadnextcloud-server-426c0341ffff262f58d1b7f031de4f0c53c8bec5.tar.gz
nextcloud-server-426c0341ffff262f58d1b7f031de4f0c53c8bec5.zip
Use typed version of IConfig::getSystemValue as much as possible
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Security')
-rw-r--r--lib/private/Security/Bruteforce/Capabilities.php2
-rw-r--r--lib/private/Security/Bruteforce/Throttler.php4
-rw-r--r--lib/private/Security/CertificateManager.php4
-rw-r--r--lib/private/Security/Crypto.php4
-rw-r--r--lib/private/Security/Hasher.php2
-rw-r--r--lib/private/Security/VerificationToken/VerificationToken.php4
6 files changed, 10 insertions, 10 deletions
diff --git a/lib/private/Security/Bruteforce/Capabilities.php b/lib/private/Security/Bruteforce/Capabilities.php
index 5de4f35f24e..60cf3086f2d 100644
--- a/lib/private/Security/Bruteforce/Capabilities.php
+++ b/lib/private/Security/Bruteforce/Capabilities.php
@@ -51,7 +51,7 @@ class Capabilities implements IPublicCapability, IInitialStateExcludedCapability
}
public function getCapabilities(): array {
- if (version_compare(\OC::$server->getConfig()->getSystemValue('version', '0.0.0.0'), '12.0.0.0', '<')) {
+ if (version_compare(\OC::$server->getConfig()->getSystemValueString('version', '0.0.0.0'), '12.0.0.0', '<')) {
return [];
}
diff --git a/lib/private/Security/Bruteforce/Throttler.php b/lib/private/Security/Bruteforce/Throttler.php
index 299cab93eb3..d5fd0984baa 100644
--- a/lib/private/Security/Bruteforce/Throttler.php
+++ b/lib/private/Security/Bruteforce/Throttler.php
@@ -112,7 +112,7 @@ class Throttler implements IThrottler {
string $ip,
array $metadata = []): void {
// No need to log if the bruteforce protection is disabled
- if ($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) {
+ if (!$this->config->getSystemValueBool('auth.bruteforce.protection.enabled', true)) {
return;
}
@@ -151,7 +151,7 @@ class Throttler implements IThrottler {
* @return bool
*/
private function isIPWhitelisted(string $ip): bool {
- if ($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) {
+ if (!$this->config->getSystemValueBool('auth.bruteforce.protection.enabled', true)) {
return true;
}
diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php
index be884654bd0..ee68f602bd1 100644
--- a/lib/private/Security/CertificateManager.php
+++ b/lib/private/Security/CertificateManager.php
@@ -67,7 +67,7 @@ class CertificateManager implements ICertificateManager {
* @return \OCP\ICertificate[]
*/
public function listCertificates(): array {
- if (!$this->config->getSystemValue('installed', false)) {
+ if (!$this->config->getSystemValueBool('installed', false)) {
return [];
}
@@ -93,7 +93,7 @@ class CertificateManager implements ICertificateManager {
}
private function hasCertificates(): bool {
- if (!$this->config->getSystemValue('installed', false)) {
+ if (!$this->config->getSystemValueBool('installed', false)) {
return false;
}
diff --git a/lib/private/Security/Crypto.php b/lib/private/Security/Crypto.php
index aeeafcc271c..2a7905376ef 100644
--- a/lib/private/Security/Crypto.php
+++ b/lib/private/Security/Crypto.php
@@ -70,7 +70,7 @@ class Crypto implements ICrypto {
*/
public function calculateHMAC(string $message, string $password = ''): string {
if ($password === '') {
- $password = $this->config->getSystemValue('secret');
+ $password = $this->config->getSystemValueString('secret');
}
// Append an "a" behind the password and hash it to prevent reusing the same password as for encryption
@@ -92,7 +92,7 @@ class Crypto implements ICrypto {
*/
public function encrypt(string $plaintext, string $password = ''): string {
if ($password === '') {
- $password = $this->config->getSystemValue('secret');
+ $password = $this->config->getSystemValueString('secret');
}
$keyMaterial = hash_hkdf('sha512', $password);
$this->cipher->setPassword(substr($keyMaterial, 0, 32));
diff --git a/lib/private/Security/Hasher.php b/lib/private/Security/Hasher.php
index 4731ba96bd3..85f69263925 100644
--- a/lib/private/Security/Hasher.php
+++ b/lib/private/Security/Hasher.php
@@ -209,7 +209,7 @@ class Hasher implements IHasher {
}
// Check if we should use PASSWORD_DEFAULT
- if ($this->config->getSystemValue('hashing_default_password', false) === true) {
+ if ($this->config->getSystemValueBool('hashing_default_password', false)) {
$default = PASSWORD_DEFAULT;
}
diff --git a/lib/private/Security/VerificationToken/VerificationToken.php b/lib/private/Security/VerificationToken/VerificationToken.php
index 2d3f902b622..52c3f62b813 100644
--- a/lib/private/Security/VerificationToken/VerificationToken.php
+++ b/lib/private/Security/VerificationToken/VerificationToken.php
@@ -82,7 +82,7 @@ class VerificationToken implements IVerificationToken {
}
try {
- $decryptedToken = $this->crypto->decrypt($encryptedToken, $passwordPrefix.$this->config->getSystemValue('secret'));
+ $decryptedToken = $this->crypto->decrypt($encryptedToken, $passwordPrefix.$this->config->getSystemValueString('secret'));
} catch (\Exception $e) {
// Retry with empty secret as a fallback for instances where the secret might not have been set by accident
try {
@@ -115,7 +115,7 @@ class VerificationToken implements IVerificationToken {
ISecureRandom::CHAR_UPPER
);
$tokenValue = $this->timeFactory->getTime() .':'. $token;
- $encryptedValue = $this->crypto->encrypt($tokenValue, $passwordPrefix . $this->config->getSystemValue('secret'));
+ $encryptedValue = $this->crypto->encrypt($tokenValue, $passwordPrefix . $this->config->getSystemValueString('secret'));
$this->config->setUserValue($user->getUID(), 'core', $subject, $encryptedValue);
$jobArgs = json_encode([
'userId' => $user->getUID(),