Skip to content

Commit 9cdac40

Browse files
committed
feat: Allow access to E2EE folder when x-e2ee-supported header is set
Signed-off-by: Louis Chemineau <[email protected]>
1 parent de5bc49 commit 9cdac40

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/Middleware/UserAgentCheckMiddleware.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ public function beforeController($controller, $methodName): void {
4949
return;
5050
}
5151

52-
if ($this->request->getHeader('x-e2ee-supported') === 'true') {
53-
return;
54-
}
55-
5652
throw new OCSForbiddenException('Client "' . $userAgent . '" is not allowed to access end-to-end encrypted content.');
5753
}
5854
}

lib/UserAgentManager.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace OCA\EndToEndEncryption;
1111

1212
use OCP\IConfig;
13+
use OCP\IRequest;
1314

1415
class UserAgentManager {
1516

@@ -21,7 +22,10 @@ class UserAgentManager {
2122
*/
2223
private array $supportedUserAgents;
2324

24-
public function __construct(IConfig $config) {
25+
public function __construct(
26+
IConfig $config,
27+
private IRequest $request,
28+
) {
2529
$this->supportedUserAgents = $config->getSystemValue('end_to_end_encryption.supported-user-agents', [
2630
'/^Mozilla\/5\.0 \(Android\) Nextcloud\-android\/(?<version>(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)).*$/' => '3.13.0',
2731
'/^Mozilla\/5\.0 \([A-Za-z ]+\) (mirall|csyncoC)\/(?<version>(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)).*$/' => '3.0.0',
@@ -51,6 +55,10 @@ public function supportsEndToEndEncryption(string $client): bool {
5155
return (version_compare($matches['version'], $minVersion) > -1);
5256
}
5357

58+
if ($this->request->getHeader('x-e2ee-supported') === 'true') {
59+
return true;
60+
}
61+
5462
return false;
5563
}
5664

0 commit comments

Comments
 (0)