aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Lib
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-07-13 09:58:24 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-08-01 16:38:06 +0200
commit38480fda3cd1f10652bc1e854207b074921e66b8 (patch)
treec4c9112123f649802c9f86d056fe6da5e89be068 /apps/files_external/lib/Lib
parent385f987a28a535e8b6b0020693daa5347093c186 (diff)
downloadnextcloud-server-38480fda3cd1f10652bc1e854207b074921e66b8.tar.gz
nextcloud-server-38480fda3cd1f10652bc1e854207b074921e66b8.zip
feat(files_external): migrate to vue
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_external/lib/Lib')
-rw-r--r--apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php4
-rw-r--r--apps/files_external/lib/Lib/StorageConfig.php23
2 files changed, 26 insertions, 1 deletions
diff --git a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
index 228366db204..a1add7c870f 100644
--- a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
+++ b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
@@ -58,6 +58,10 @@ class SessionCredentials extends AuthMechanism {
throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
}
+ if ($user === null) {
+ throw new StorageAuthException('Session unavailable');
+ }
+
if ($credentials->getUID() !== $user->getUID()) {
throw new StorageAuthException('Session credentials for storage owner not available');
}
diff --git a/apps/files_external/lib/Lib/StorageConfig.php b/apps/files_external/lib/Lib/StorageConfig.php
index be61d2982c0..8cb59f70892 100644
--- a/apps/files_external/lib/Lib/StorageConfig.php
+++ b/apps/files_external/lib/Lib/StorageConfig.php
@@ -397,11 +397,17 @@ class StorageConfig implements \JsonSerializable {
/**
* Serialize config to JSON
*/
- public function jsonSerialize(): array {
+ public function jsonSerialize(bool $obfuscate = false): array {
$result = [];
if (!is_null($this->id)) {
$result['id'] = $this->id;
}
+
+ // obfuscate sensitive data if requested
+ if ($obfuscate) {
+ $this->formatStorageForUI();
+ }
+
$result['mountPoint'] = $this->mountPoint;
$result['backend'] = $this->backend->getIdentifier();
$result['authMechanism'] = $this->authMechanism->getIdentifier();
@@ -428,4 +434,19 @@ class StorageConfig implements \JsonSerializable {
$result['type'] = ($this->getType() === self::MOUNT_TYPE_PERSONAl) ? 'personal': 'system';
return $result;
}
+
+ protected function formatStorageForUI(): void {
+ /** @var DefinitionParameter[] $parameters */
+ $parameters = array_merge($this->getBackend()->getParameters(), $this->getAuthMechanism()->getParameters());
+
+ $options = $this->getBackendOptions();
+ foreach ($options as $key => $value) {
+ foreach ($parameters as $parameter) {
+ if ($parameter->getName() === $key && $parameter->getType() === DefinitionParameter::VALUE_PASSWORD) {
+ $this->setBackendOption($key, DefinitionParameter::UNMODIFIED_PLACEHOLDER);
+ break;
+ }
+ }
+ }
+ }
}