Passed
Push — master ( 0571fd...48a8f0 )
by Blizzz
19:19 queued 08:57
created
core/Command/Maintenance/Mode.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -32,54 +32,54 @@
 block discarded – undo
32 32
 
33 33
 class Mode extends Command {
34 34
 
35
-	/** @var IConfig */
36
-	protected $config;
35
+    /** @var IConfig */
36
+    protected $config;
37 37
 
38
-	public function __construct(IConfig $config) {
39
-		$this->config = $config;
40
-		parent::__construct();
41
-	}
38
+    public function __construct(IConfig $config) {
39
+        $this->config = $config;
40
+        parent::__construct();
41
+    }
42 42
 
43
-	protected function configure() {
44
-		$this
45
-			->setName('maintenance:mode')
46
-			->setDescription('set maintenance mode')
47
-			->addOption(
48
-				'on',
49
-				null,
50
-				InputOption::VALUE_NONE,
51
-				'enable maintenance mode'
52
-			)
53
-			->addOption(
54
-				'off',
55
-				null,
56
-				InputOption::VALUE_NONE,
57
-				'disable maintenance mode'
58
-			);
59
-	}
43
+    protected function configure() {
44
+        $this
45
+            ->setName('maintenance:mode')
46
+            ->setDescription('set maintenance mode')
47
+            ->addOption(
48
+                'on',
49
+                null,
50
+                InputOption::VALUE_NONE,
51
+                'enable maintenance mode'
52
+            )
53
+            ->addOption(
54
+                'off',
55
+                null,
56
+                InputOption::VALUE_NONE,
57
+                'disable maintenance mode'
58
+            );
59
+    }
60 60
 
61
-	protected function execute(InputInterface $input, OutputInterface $output) {
62
-		$maintenanceMode = $this->config->getSystemValueBool('maintenance');
63
-		if ($input->getOption('on')) {
64
-			if ($maintenanceMode === false) {
65
-				$this->config->setSystemValue('maintenance', true);
66
-				$output->writeln('Maintenance mode enabled');
67
-			} else {
68
-				$output->writeln('Maintenance mode already enabled');
69
-			}
70
-		} elseif ($input->getOption('off')) {
71
-			if ($maintenanceMode === true) {
72
-				$this->config->setSystemValue('maintenance', false);
73
-				$output->writeln('Maintenance mode disabled');
74
-			} else {
75
-				$output->writeln('Maintenance mode already disabled');
76
-			}
77
-		} else {
78
-			if ($maintenanceMode) {
79
-				$output->writeln('Maintenance mode is currently enabled');
80
-			} else {
81
-				$output->writeln('Maintenance mode is currently disabled');
82
-			}
83
-		}
84
-	}
61
+    protected function execute(InputInterface $input, OutputInterface $output) {
62
+        $maintenanceMode = $this->config->getSystemValueBool('maintenance');
63
+        if ($input->getOption('on')) {
64
+            if ($maintenanceMode === false) {
65
+                $this->config->setSystemValue('maintenance', true);
66
+                $output->writeln('Maintenance mode enabled');
67
+            } else {
68
+                $output->writeln('Maintenance mode already enabled');
69
+            }
70
+        } elseif ($input->getOption('off')) {
71
+            if ($maintenanceMode === true) {
72
+                $this->config->setSystemValue('maintenance', false);
73
+                $output->writeln('Maintenance mode disabled');
74
+            } else {
75
+                $output->writeln('Maintenance mode already disabled');
76
+            }
77
+        } else {
78
+            if ($maintenanceMode) {
79
+                $output->writeln('Maintenance mode is currently enabled');
80
+            } else {
81
+                $output->writeln('Maintenance mode is currently disabled');
82
+            }
83
+        }
84
+    }
85 85
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,19 +31,19 @@
 block discarded – undo
31 31
 
32 32
 class AddClenupLoginFlowV2BackgroundJob implements IRepairStep {
33 33
 
34
-	/** @var IJobList */
35
-	private $jobList;
34
+    /** @var IJobList */
35
+    private $jobList;
36 36
 
37
-	public function __construct(IJobList $jobList) {
38
-		$this->jobList = $jobList;
39
-	}
37
+    public function __construct(IJobList $jobList) {
38
+        $this->jobList = $jobList;
39
+    }
40 40
 
41
-	public function getName(): string {
42
-		return 'Add background job to cleanup login flow v2 tokens';
43
-	}
41
+    public function getName(): string {
42
+        return 'Add background job to cleanup login flow v2 tokens';
43
+    }
44 44
 
45
-	public function run(IOutput $output) {
46
-		$this->jobList->add(CleanupLoginFlowV2::class);
47
-	}
45
+    public function run(IOutput $output) {
46
+        $this->jobList->add(CleanupLoginFlowV2::class);
47
+    }
48 48
 
49 49
 }
Please login to merge, or discard this patch.
core/Data/LoginFlowV2Credentials.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -25,47 +25,47 @@
 block discarded – undo
25 25
 namespace OC\Core\Data;
26 26
 
27 27
 class LoginFlowV2Credentials implements \JsonSerializable {
28
-	/** @var string */
29
-	private $server;
30
-	/** @var string */
31
-	private $loginName;
32
-	/** @var string */
33
-	private $appPassword;
28
+    /** @var string */
29
+    private $server;
30
+    /** @var string */
31
+    private $loginName;
32
+    /** @var string */
33
+    private $appPassword;
34 34
 
35
-	public function __construct(string $server, string $loginName, string $appPassword) {
36
-		$this->server = $server;
37
-		$this->loginName = $loginName;
38
-		$this->appPassword = $appPassword;
39
-	}
35
+    public function __construct(string $server, string $loginName, string $appPassword) {
36
+        $this->server = $server;
37
+        $this->loginName = $loginName;
38
+        $this->appPassword = $appPassword;
39
+    }
40 40
 
41
-	/**
42
-	 * @return string
43
-	 */
44
-	public function getServer(): string {
45
-		return $this->server;
46
-	}
41
+    /**
42
+     * @return string
43
+     */
44
+    public function getServer(): string {
45
+        return $this->server;
46
+    }
47 47
 
48
-	/**
49
-	 * @return string
50
-	 */
51
-	public function getLoginName(): string {
52
-		return $this->loginName;
53
-	}
48
+    /**
49
+     * @return string
50
+     */
51
+    public function getLoginName(): string {
52
+        return $this->loginName;
53
+    }
54 54
 
55
-	/**
56
-	 * @return string
57
-	 */
58
-	public function getAppPassword(): string {
59
-		return $this->appPassword;
60
-	}
55
+    /**
56
+     * @return string
57
+     */
58
+    public function getAppPassword(): string {
59
+        return $this->appPassword;
60
+    }
61 61
 
62
-	public function jsonSerialize(): array {
63
-		return [
64
-			'server' => $this->server,
65
-			'loginName' => $this->loginName,
66
-			'appPassword' => $this->appPassword,
67
-		];
68
-	}
62
+    public function jsonSerialize(): array {
63
+        return [
64
+            'server' => $this->server,
65
+            'loginName' => $this->loginName,
66
+            'appPassword' => $this->appPassword,
67
+        ];
68
+    }
69 69
 
70 70
 
71 71
 }
Please login to merge, or discard this patch.
core/Service/LoginFlowV2Service.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
 	private function hashToken(string $token): string {
213 213
 		$secret = $this->config->getSystemValue('secret');
214
-		return hash('sha512', $token . $secret);
214
+		return hash('sha512', $token.$secret);
215 215
 	}
216 216
 
217 217
 	private function getKeyPair(): array {
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		while ($error = openssl_error_string()) {
242 242
 			$errors[] = $error;
243 243
 		}
244
-		$this->logger->critical('Something is wrong with your openssl setup: ' . implode(', ', $errors));
244
+		$this->logger->critical('Something is wrong with your openssl setup: '.implode(', ', $errors));
245 245
 	}
246 246
 
247 247
 	private function encryptPassword(string $password, string $publicKey): string {
Please login to merge, or discard this patch.
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -42,215 +42,215 @@
 block discarded – undo
42 42
 
43 43
 class LoginFlowV2Service {
44 44
 
45
-	/** @var LoginFlowV2Mapper */
46
-	private $mapper;
47
-	/** @var ISecureRandom */
48
-	private $random;
49
-	/** @var ITimeFactory */
50
-	private $time;
51
-	/** @var IConfig */
52
-	private $config;
53
-	/** @var ICrypto */
54
-	private $crypto;
55
-	/** @var ILogger */
56
-	private $logger;
57
-	/** @var IProvider */
58
-	private $tokenProvider;
59
-
60
-	public function __construct(LoginFlowV2Mapper $mapper,
61
-								ISecureRandom $random,
62
-								ITimeFactory $time,
63
-								IConfig $config,
64
-								ICrypto $crypto,
65
-								ILogger $logger,
66
-								IProvider $tokenProvider) {
67
-		$this->mapper = $mapper;
68
-		$this->random = $random;
69
-		$this->time = $time;
70
-		$this->config = $config;
71
-		$this->crypto = $crypto;
72
-		$this->logger = $logger;
73
-		$this->tokenProvider = $tokenProvider;
74
-	}
75
-
76
-	/**
77
-	 * @param string $pollToken
78
-	 * @return LoginFlowV2Credentials
79
-	 * @throws LoginFlowV2NotFoundException
80
-	 */
81
-	public function poll(string $pollToken): LoginFlowV2Credentials {
82
-		try {
83
-			$data = $this->mapper->getByPollToken($this->hashToken($pollToken));
84
-		} catch (DoesNotExistException $e) {
85
-			throw new LoginFlowV2NotFoundException('Invalid token');
86
-		}
87
-
88
-		$loginName = $data->getLoginName();
89
-		$server = $data->getServer();
90
-		$appPassword = $data->getAppPassword();
91
-
92
-		if ($loginName === null || $server === null || $appPassword === null) {
93
-			throw new LoginFlowV2NotFoundException('Token not yet ready');
94
-		}
95
-
96
-		// Remove the data from the DB
97
-		$this->mapper->delete($data);
98
-
99
-		try {
100
-			// Decrypt the apptoken
101
-			$privateKey = $this->crypto->decrypt($data->getPrivateKey(), $pollToken);
102
-			$appPassword = $this->decryptPassword($data->getAppPassword(), $privateKey);
103
-		} catch (\Exception $e) {
104
-			throw new LoginFlowV2NotFoundException('Apptoken could not be decrypted');
105
-		}
106
-
107
-		return new LoginFlowV2Credentials($server, $loginName, $appPassword);
108
-	}
109
-
110
-	/**
111
-	 * @param string $loginToken
112
-	 * @return LoginFlowV2
113
-	 * @throws LoginFlowV2NotFoundException
114
-	 */
115
-	public function getByLoginToken(string $loginToken): LoginFlowV2 {
116
-		try {
117
-			return $this->mapper->getByLoginToken($loginToken);
118
-		} catch (DoesNotExistException $e) {
119
-			throw new LoginFlowV2NotFoundException('Login token invalid');
120
-		}
121
-	}
122
-
123
-	/**
124
-	 * @param string $loginToken
125
-	 * @return bool returns true if the start was successfull. False if not.
126
-	 */
127
-	public function startLoginFlow(string $loginToken): bool {
128
-		try {
129
-			$data = $this->mapper->getByLoginToken($loginToken);
130
-		} catch (DoesNotExistException $e) {
131
-			return false;
132
-		}
133
-
134
-		$data->setStarted(1);
135
-		$this->mapper->update($data);
136
-
137
-		return true;
138
-	}
139
-
140
-	/**
141
-	 * @param string $loginToken
142
-	 * @param string $sessionId
143
-	 * @param string $server
144
-	 * @param string $userId
145
-	 * @return bool true if the flow was successfully completed false otherwise
146
-	 */
147
-	public function flowDone(string $loginToken, string $sessionId, string $server, string $userId): bool {
148
-		try {
149
-			$data = $this->mapper->getByLoginToken($loginToken);
150
-		} catch (DoesNotExistException $e) {
151
-			return false;
152
-		}
153
-
154
-		try {
155
-			$sessionToken = $this->tokenProvider->getToken($sessionId);
156
-			$loginName = $sessionToken->getLoginName();
157
-			try {
158
-				$password = $this->tokenProvider->getPassword($sessionToken, $sessionId);
159
-			} catch (PasswordlessTokenException $ex) {
160
-				$password = null;
161
-			}
162
-		} catch (InvalidTokenException $ex) {
163
-			return false;
164
-		}
165
-
166
-		$appPassword = $this->random->generate(72, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS);
167
-		$this->tokenProvider->generateToken(
168
-			$appPassword,
169
-			$userId,
170
-			$loginName,
171
-			$password,
172
-			$data->getClientName(),
173
-			IToken::PERMANENT_TOKEN,
174
-			IToken::DO_NOT_REMEMBER
175
-		);
176
-
177
-		$data->setLoginName($loginName);
178
-		$data->setServer($server);
179
-
180
-		// Properly encrypt
181
-		$data->setAppPassword($this->encryptPassword($appPassword, $data->getPublicKey()));
182
-
183
-		$this->mapper->update($data);
184
-		return true;
185
-	}
186
-
187
-	public function createTokens(string $userAgent): LoginFlowV2Tokens {
188
-		$flow = new LoginFlowV2();
189
-		$pollToken = $this->random->generate(128, ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER);
190
-		$loginToken = $this->random->generate(128, ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER);
191
-		$flow->setPollToken($this->hashToken($pollToken));
192
-		$flow->setLoginToken($loginToken);
193
-		$flow->setStarted(0);
194
-		$flow->setTimestamp($this->time->getTime());
195
-		$flow->setClientName($userAgent);
196
-
197
-		[$publicKey, $privateKey] = $this->getKeyPair();
198
-		$privateKey = $this->crypto->encrypt($privateKey, $pollToken);
199
-
200
-		$flow->setPublicKey($publicKey);
201
-		$flow->setPrivateKey($privateKey);
202
-
203
-		$this->mapper->insert($flow);
204
-
205
-		return new LoginFlowV2Tokens($loginToken, $pollToken);
206
-	}
207
-
208
-	private function hashToken(string $token): string {
209
-		$secret = $this->config->getSystemValue('secret');
210
-		return hash('sha512', $token . $secret);
211
-	}
212
-
213
-	private function getKeyPair(): array {
214
-		$config = array_merge([
215
-			'digest_alg' => 'sha512',
216
-			'private_key_bits' => 2048,
217
-		], $this->config->getSystemValue('openssl', []));
218
-
219
-		// Generate new key
220
-		$res = openssl_pkey_new($config);
221
-		if ($res === false) {
222
-			$this->logOpensslError();
223
-			throw new \RuntimeException('Could not initialize keys');
224
-		}
225
-
226
-		openssl_pkey_export($res, $privateKey);
227
-
228
-		// Extract the public key from $res to $pubKey
229
-		$publicKey = openssl_pkey_get_details($res);
230
-		$publicKey = $publicKey['key'];
231
-
232
-		return [$publicKey, $privateKey];
233
-	}
234
-
235
-	private function logOpensslError(): void {
236
-		$errors = [];
237
-		while ($error = openssl_error_string()) {
238
-			$errors[] = $error;
239
-		}
240
-		$this->logger->critical('Something is wrong with your openssl setup: ' . implode(', ', $errors));
241
-	}
242
-
243
-	private function encryptPassword(string $password, string $publicKey): string {
244
-		openssl_public_encrypt($password, $encryptedPassword, $publicKey, OPENSSL_PKCS1_OAEP_PADDING);
245
-		$encryptedPassword = base64_encode($encryptedPassword);
246
-
247
-		return $encryptedPassword;
248
-	}
249
-
250
-	private function decryptPassword(string $encryptedPassword, string $privateKey): string {
251
-		$encryptedPassword = base64_decode($encryptedPassword);
252
-		openssl_private_decrypt($encryptedPassword, $password, $privateKey, OPENSSL_PKCS1_OAEP_PADDING);
253
-
254
-		return $password;
255
-	}
45
+    /** @var LoginFlowV2Mapper */
46
+    private $mapper;
47
+    /** @var ISecureRandom */
48
+    private $random;
49
+    /** @var ITimeFactory */
50
+    private $time;
51
+    /** @var IConfig */
52
+    private $config;
53
+    /** @var ICrypto */
54
+    private $crypto;
55
+    /** @var ILogger */
56
+    private $logger;
57
+    /** @var IProvider */
58
+    private $tokenProvider;
59
+
60
+    public function __construct(LoginFlowV2Mapper $mapper,
61
+                                ISecureRandom $random,
62
+                                ITimeFactory $time,
63
+                                IConfig $config,
64
+                                ICrypto $crypto,
65
+                                ILogger $logger,
66
+                                IProvider $tokenProvider) {
67
+        $this->mapper = $mapper;
68
+        $this->random = $random;
69
+        $this->time = $time;
70
+        $this->config = $config;
71
+        $this->crypto = $crypto;
72
+        $this->logger = $logger;
73
+        $this->tokenProvider = $tokenProvider;
74
+    }
75
+
76
+    /**
77
+     * @param string $pollToken
78
+     * @return LoginFlowV2Credentials
79
+     * @throws LoginFlowV2NotFoundException
80
+     */
81
+    public function poll(string $pollToken): LoginFlowV2Credentials {
82
+        try {
83
+            $data = $this->mapper->getByPollToken($this->hashToken($pollToken));
84
+        } catch (DoesNotExistException $e) {
85
+            throw new LoginFlowV2NotFoundException('Invalid token');
86
+        }
87
+
88
+        $loginName = $data->getLoginName();
89
+        $server = $data->getServer();
90
+        $appPassword = $data->getAppPassword();
91
+
92
+        if ($loginName === null || $server === null || $appPassword === null) {
93
+            throw new LoginFlowV2NotFoundException('Token not yet ready');
94
+        }
95
+
96
+        // Remove the data from the DB
97
+        $this->mapper->delete($data);
98
+
99
+        try {
100
+            // Decrypt the apptoken
101
+            $privateKey = $this->crypto->decrypt($data->getPrivateKey(), $pollToken);
102
+            $appPassword = $this->decryptPassword($data->getAppPassword(), $privateKey);
103
+        } catch (\Exception $e) {
104
+            throw new LoginFlowV2NotFoundException('Apptoken could not be decrypted');
105
+        }
106
+
107
+        return new LoginFlowV2Credentials($server, $loginName, $appPassword);
108
+    }
109
+
110
+    /**
111
+     * @param string $loginToken
112
+     * @return LoginFlowV2
113
+     * @throws LoginFlowV2NotFoundException
114
+     */
115
+    public function getByLoginToken(string $loginToken): LoginFlowV2 {
116
+        try {
117
+            return $this->mapper->getByLoginToken($loginToken);
118
+        } catch (DoesNotExistException $e) {
119
+            throw new LoginFlowV2NotFoundException('Login token invalid');
120
+        }
121
+    }
122
+
123
+    /**
124
+     * @param string $loginToken
125
+     * @return bool returns true if the start was successfull. False if not.
126
+     */
127
+    public function startLoginFlow(string $loginToken): bool {
128
+        try {
129
+            $data = $this->mapper->getByLoginToken($loginToken);
130
+        } catch (DoesNotExistException $e) {
131
+            return false;
132
+        }
133
+
134
+        $data->setStarted(1);
135
+        $this->mapper->update($data);
136
+
137
+        return true;
138
+    }
139
+
140
+    /**
141
+     * @param string $loginToken
142
+     * @param string $sessionId
143
+     * @param string $server
144
+     * @param string $userId
145
+     * @return bool true if the flow was successfully completed false otherwise
146
+     */
147
+    public function flowDone(string $loginToken, string $sessionId, string $server, string $userId): bool {
148
+        try {
149
+            $data = $this->mapper->getByLoginToken($loginToken);
150
+        } catch (DoesNotExistException $e) {
151
+            return false;
152
+        }
153
+
154
+        try {
155
+            $sessionToken = $this->tokenProvider->getToken($sessionId);
156
+            $loginName = $sessionToken->getLoginName();
157
+            try {
158
+                $password = $this->tokenProvider->getPassword($sessionToken, $sessionId);
159
+            } catch (PasswordlessTokenException $ex) {
160
+                $password = null;
161
+            }
162
+        } catch (InvalidTokenException $ex) {
163
+            return false;
164
+        }
165
+
166
+        $appPassword = $this->random->generate(72, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS);
167
+        $this->tokenProvider->generateToken(
168
+            $appPassword,
169
+            $userId,
170
+            $loginName,
171
+            $password,
172
+            $data->getClientName(),
173
+            IToken::PERMANENT_TOKEN,
174
+            IToken::DO_NOT_REMEMBER
175
+        );
176
+
177
+        $data->setLoginName($loginName);
178
+        $data->setServer($server);
179
+
180
+        // Properly encrypt
181
+        $data->setAppPassword($this->encryptPassword($appPassword, $data->getPublicKey()));
182
+
183
+        $this->mapper->update($data);
184
+        return true;
185
+    }
186
+
187
+    public function createTokens(string $userAgent): LoginFlowV2Tokens {
188
+        $flow = new LoginFlowV2();
189
+        $pollToken = $this->random->generate(128, ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER);
190
+        $loginToken = $this->random->generate(128, ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER);
191
+        $flow->setPollToken($this->hashToken($pollToken));
192
+        $flow->setLoginToken($loginToken);
193
+        $flow->setStarted(0);
194
+        $flow->setTimestamp($this->time->getTime());
195
+        $flow->setClientName($userAgent);
196
+
197
+        [$publicKey, $privateKey] = $this->getKeyPair();
198
+        $privateKey = $this->crypto->encrypt($privateKey, $pollToken);
199
+
200
+        $flow->setPublicKey($publicKey);
201
+        $flow->setPrivateKey($privateKey);
202
+
203
+        $this->mapper->insert($flow);
204
+
205
+        return new LoginFlowV2Tokens($loginToken, $pollToken);
206
+    }
207
+
208
+    private function hashToken(string $token): string {
209
+        $secret = $this->config->getSystemValue('secret');
210
+        return hash('sha512', $token . $secret);
211
+    }
212
+
213
+    private function getKeyPair(): array {
214
+        $config = array_merge([
215
+            'digest_alg' => 'sha512',
216
+            'private_key_bits' => 2048,
217
+        ], $this->config->getSystemValue('openssl', []));
218
+
219
+        // Generate new key
220
+        $res = openssl_pkey_new($config);
221
+        if ($res === false) {
222
+            $this->logOpensslError();
223
+            throw new \RuntimeException('Could not initialize keys');
224
+        }
225
+
226
+        openssl_pkey_export($res, $privateKey);
227
+
228
+        // Extract the public key from $res to $pubKey
229
+        $publicKey = openssl_pkey_get_details($res);
230
+        $publicKey = $publicKey['key'];
231
+
232
+        return [$publicKey, $privateKey];
233
+    }
234
+
235
+    private function logOpensslError(): void {
236
+        $errors = [];
237
+        while ($error = openssl_error_string()) {
238
+            $errors[] = $error;
239
+        }
240
+        $this->logger->critical('Something is wrong with your openssl setup: ' . implode(', ', $errors));
241
+    }
242
+
243
+    private function encryptPassword(string $password, string $publicKey): string {
244
+        openssl_public_encrypt($password, $encryptedPassword, $publicKey, OPENSSL_PKCS1_OAEP_PADDING);
245
+        $encryptedPassword = base64_encode($encryptedPassword);
246
+
247
+        return $encryptedPassword;
248
+    }
249
+
250
+    private function decryptPassword(string $encryptedPassword, string $privateKey): string {
251
+        $encryptedPassword = base64_decode($encryptedPassword);
252
+        openssl_private_decrypt($encryptedPassword, $password, $privateKey, OPENSSL_PKCS1_OAEP_PADDING);
253
+
254
+        return $password;
255
+    }
256 256
 }
Please login to merge, or discard this patch.
core/BackgroundJobs/CleanupLoginFlowV2.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@
 block discarded – undo
30 30
 
31 31
 class CleanupLoginFlowV2 extends TimedJob {
32 32
 
33
-	/** @var LoginFlowV2Mapper */
34
-	private $loginFlowV2Mapper;
33
+    /** @var LoginFlowV2Mapper */
34
+    private $loginFlowV2Mapper;
35 35
 
36
-	public function __construct(ITimeFactory $time, LoginFlowV2Mapper $loginFlowV2Mapper) {
37
-		parent::__construct($time);
38
-		$this->loginFlowV2Mapper = $loginFlowV2Mapper;
36
+    public function __construct(ITimeFactory $time, LoginFlowV2Mapper $loginFlowV2Mapper) {
37
+        parent::__construct($time);
38
+        $this->loginFlowV2Mapper = $loginFlowV2Mapper;
39 39
 
40
-		$this->setInterval(3600);
41
-	}
40
+        $this->setInterval(3600);
41
+    }
42 42
 
43
-	protected function run($argument) {
44
-		$this->loginFlowV2Mapper->cleanup();
45
-	}
43
+    protected function run($argument) {
44
+        $this->loginFlowV2Mapper->cleanup();
45
+    }
46 46
 }
Please login to merge, or discard this patch.
core/Db/LoginFlowV2.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -49,37 +49,37 @@
 block discarded – undo
49 49
  * @method void setAppPassword(string $appPassword)
50 50
  */
51 51
 class LoginFlowV2 extends Entity {
52
-	/** @var int */
53
-	protected $timestamp;
54
-	/** @var int */
55
-	protected $started;
56
-	/** @var string */
57
-	protected $pollToken;
58
-	/** @var string */
59
-	protected $loginToken;
60
-	/** @var string */
61
-	protected $publicKey;
62
-	/** @var string */
63
-	protected $privateKey;
64
-	/** @var string */
65
-	protected $clientName;
66
-	/** @var string */
67
-	protected $loginName;
68
-	/** @var string */
69
-	protected $server;
70
-	/** @var string */
71
-	protected $appPassword;
52
+    /** @var int */
53
+    protected $timestamp;
54
+    /** @var int */
55
+    protected $started;
56
+    /** @var string */
57
+    protected $pollToken;
58
+    /** @var string */
59
+    protected $loginToken;
60
+    /** @var string */
61
+    protected $publicKey;
62
+    /** @var string */
63
+    protected $privateKey;
64
+    /** @var string */
65
+    protected $clientName;
66
+    /** @var string */
67
+    protected $loginName;
68
+    /** @var string */
69
+    protected $server;
70
+    /** @var string */
71
+    protected $appPassword;
72 72
 
73
-	public function __construct() {
74
-		$this->addType('timestamp', 'int');
75
-		$this->addType('started', 'int');
76
-		$this->addType('pollToken', 'string');
77
-		$this->addType('loginToken', 'string');
78
-		$this->addType('publicKey', 'string');
79
-		$this->addType('privateKey', 'string');
80
-		$this->addType('clientName', 'string');
81
-		$this->addType('loginName', 'string');
82
-		$this->addType('server', 'string');
83
-		$this->addType('appPassword', 'string');
84
-	}
73
+    public function __construct() {
74
+        $this->addType('timestamp', 'int');
75
+        $this->addType('started', 'int');
76
+        $this->addType('pollToken', 'string');
77
+        $this->addType('loginToken', 'string');
78
+        $this->addType('publicKey', 'string');
79
+        $this->addType('privateKey', 'string');
80
+        $this->addType('clientName', 'string');
81
+        $this->addType('loginName', 'string');
82
+        $this->addType('server', 'string');
83
+        $this->addType('appPassword', 'string');
84
+    }
85 85
 }
Please login to merge, or discard this patch.
core/Db/LoginFlowV2Mapper.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -30,71 +30,71 @@
 block discarded – undo
30 30
 use OCP\IDBConnection;
31 31
 
32 32
 class LoginFlowV2Mapper extends QBMapper {
33
-	private const lifetime = 1200;
33
+    private const lifetime = 1200;
34 34
 
35
-	/** @var ITimeFactory */
36
-	private $timeFactory;
35
+    /** @var ITimeFactory */
36
+    private $timeFactory;
37 37
 
38
-	public function __construct(IDBConnection $db, ITimeFactory $timeFactory) {
39
-		parent::__construct($db, 'login_flow_v2', LoginFlowV2::class);
40
-		$this->timeFactory = $timeFactory;
41
-	}
38
+    public function __construct(IDBConnection $db, ITimeFactory $timeFactory) {
39
+        parent::__construct($db, 'login_flow_v2', LoginFlowV2::class);
40
+        $this->timeFactory = $timeFactory;
41
+    }
42 42
 
43
-	/**
44
-	 * @param string $pollToken
45
-	 * @return LoginFlowV2
46
-	 * @throws DoesNotExistException
47
-	 */
48
-	public function getByPollToken(string $pollToken): LoginFlowV2 {
49
-		$qb = $this->db->getQueryBuilder();
50
-		$qb->select('*')
51
-			->from($this->getTableName())
52
-			->where(
53
-				$qb->expr()->eq('poll_token', $qb->createNamedParameter($pollToken))
54
-			);
43
+    /**
44
+     * @param string $pollToken
45
+     * @return LoginFlowV2
46
+     * @throws DoesNotExistException
47
+     */
48
+    public function getByPollToken(string $pollToken): LoginFlowV2 {
49
+        $qb = $this->db->getQueryBuilder();
50
+        $qb->select('*')
51
+            ->from($this->getTableName())
52
+            ->where(
53
+                $qb->expr()->eq('poll_token', $qb->createNamedParameter($pollToken))
54
+            );
55 55
 
56
-		$entity = $this->findEntity($qb);
57
-		return $this->validateTimestamp($entity);
58
-	}
56
+        $entity = $this->findEntity($qb);
57
+        return $this->validateTimestamp($entity);
58
+    }
59 59
 
60
-	/**
61
-	 * @param string $loginToken
62
-	 * @return LoginFlowV2
63
-	 * @throws DoesNotExistException
64
-	 */
65
-	public function getByLoginToken(string $loginToken): LoginFlowV2 {
66
-		$qb = $this->db->getQueryBuilder();
67
-		$qb->select('*')
68
-			->from($this->getTableName())
69
-			->where(
70
-				$qb->expr()->eq('login_token', $qb->createNamedParameter($loginToken))
71
-			);
60
+    /**
61
+     * @param string $loginToken
62
+     * @return LoginFlowV2
63
+     * @throws DoesNotExistException
64
+     */
65
+    public function getByLoginToken(string $loginToken): LoginFlowV2 {
66
+        $qb = $this->db->getQueryBuilder();
67
+        $qb->select('*')
68
+            ->from($this->getTableName())
69
+            ->where(
70
+                $qb->expr()->eq('login_token', $qb->createNamedParameter($loginToken))
71
+            );
72 72
 
73
-		$entity = $this->findEntity($qb);
74
-		return $this->validateTimestamp($entity);
75
-	}
73
+        $entity = $this->findEntity($qb);
74
+        return $this->validateTimestamp($entity);
75
+    }
76 76
 
77
-	public function cleanup(): void {
78
-		$qb = $this->db->getQueryBuilder();
79
-		$qb->delete($this->getTableName())
80
-			->where(
81
-				$qb->expr()->lt('timestamp', $qb->createNamedParameter($this->timeFactory->getTime() - self::lifetime))
82
-			);
77
+    public function cleanup(): void {
78
+        $qb = $this->db->getQueryBuilder();
79
+        $qb->delete($this->getTableName())
80
+            ->where(
81
+                $qb->expr()->lt('timestamp', $qb->createNamedParameter($this->timeFactory->getTime() - self::lifetime))
82
+            );
83 83
 
84
-		$qb->execute();
85
-	}
84
+        $qb->execute();
85
+    }
86 86
 
87
-	/**
88
-	 * @param LoginFlowV2 $flowV2
89
-	 * @return LoginFlowV2
90
-	 * @throws DoesNotExistException
91
-	 */
92
-	private function validateTimestamp(LoginFlowV2 $flowV2): LoginFlowV2 {
93
-		if ($flowV2->getTimestamp() < ($this->timeFactory->getTime() - self::lifetime)) {
94
-			$this->delete($flowV2);
95
-			throw new DoesNotExistException('Token expired');
96
-		}
87
+    /**
88
+     * @param LoginFlowV2 $flowV2
89
+     * @return LoginFlowV2
90
+     * @throws DoesNotExistException
91
+     */
92
+    private function validateTimestamp(LoginFlowV2 $flowV2): LoginFlowV2 {
93
+        if ($flowV2->getTimestamp() < ($this->timeFactory->getTime() - self::lifetime)) {
94
+            $this->delete($flowV2);
95
+            throw new DoesNotExistException('Token expired');
96
+        }
97 97
 
98
-		return $flowV2;
99
-	}
98
+        return $flowV2;
99
+    }
100 100
 }
Please login to merge, or discard this patch.
lib/public/Group/Backend/IHideFromCollaborationBackend.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@
 block discarded – undo
27 27
  * Allow the backend to mark groups to be excluded from being shown in search dialogs
28 28
  */
29 29
 interface IHideFromCollaborationBackend {
30
-	/**
31
-	 * Check if a group should be hidden from search dialogs
32
-	 *
33
-	 * @param string $groupId
34
-	 * @return bool
35
-	 * @since 16.0.0
36
-	 */
37
-	public function hideGroup(string $groupId): bool;
30
+    /**
31
+     * Check if a group should be hidden from search dialogs
32
+     *
33
+     * @param string $groupId
34
+     * @return bool
35
+     * @since 16.0.0
36
+     */
37
+    public function hideGroup(string $groupId): bool;
38 38
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/AutoComplete/AutoCompleteEvent.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -30,70 +30,70 @@
 block discarded – undo
30 30
  */
31 31
 class AutoCompleteEvent extends GenericEvent {
32 32
 
33
-	/**
34
-	 * @param array $arguments
35
-	 * @since 16.0.0
36
-	 */
37
-	public function __construct(array $arguments) {
38
-		parent::__construct(null, $arguments);
39
-	}
33
+    /**
34
+     * @param array $arguments
35
+     * @since 16.0.0
36
+     */
37
+    public function __construct(array $arguments) {
38
+        parent::__construct(null, $arguments);
39
+    }
40 40
 
41
-	/**
42
-	 * @since 16.0.0
43
-	 */
44
-	public function getResults(): array {
45
-		return $this->getArgument('results');
46
-	}
41
+    /**
42
+     * @since 16.0.0
43
+     */
44
+    public function getResults(): array {
45
+        return $this->getArgument('results');
46
+    }
47 47
 
48
-	/**
49
-	 * @param array $results
50
-	 * @since 16.0.0
51
-	 */
52
-	public function setResults(array $results): void {
53
-		$this->setArgument('results', $results);
54
-	}
48
+    /**
49
+     * @param array $results
50
+     * @since 16.0.0
51
+     */
52
+    public function setResults(array $results): void {
53
+        $this->setArgument('results', $results);
54
+    }
55 55
 
56
-	/**
57
-	 * @since 16.0.0
58
-	 */
59
-	public function getSearchTerm(): string {
60
-		return $this->getArgument('search');
61
-	}
56
+    /**
57
+     * @since 16.0.0
58
+     */
59
+    public function getSearchTerm(): string {
60
+        return $this->getArgument('search');
61
+    }
62 62
 
63
-	/**
64
-	 * @return int[]
65
-	 * @since 16.0.0
66
-	 */
67
-	public function getShareTypes(): array {
68
-		return $this->getArgument('shareTypes');
69
-	}
63
+    /**
64
+     * @return int[]
65
+     * @since 16.0.0
66
+     */
67
+    public function getShareTypes(): array {
68
+        return $this->getArgument('shareTypes');
69
+    }
70 70
 
71
-	/**
72
-	 * @since 16.0.0
73
-	 */
74
-	public function getItemType(): string {
75
-		return $this->getArgument('itemType');
76
-	}
71
+    /**
72
+     * @since 16.0.0
73
+     */
74
+    public function getItemType(): string {
75
+        return $this->getArgument('itemType');
76
+    }
77 77
 
78
-	/**
79
-	 * @since 16.0.0
80
-	 */
81
-	public function getItemId(): string {
82
-		return $this->getArgument('itemId');
83
-	}
78
+    /**
79
+     * @since 16.0.0
80
+     */
81
+    public function getItemId(): string {
82
+        return $this->getArgument('itemId');
83
+    }
84 84
 
85
-	/**
86
-	 * @since 16.0.0
87
-	 */
88
-	public function getSorter(): string {
89
-		return $this->getArgument('sorter');
90
-	}
85
+    /**
86
+     * @since 16.0.0
87
+     */
88
+    public function getSorter(): string {
89
+        return $this->getArgument('sorter');
90
+    }
91 91
 
92
-	/**
93
-	 * @since 16.0.0
94
-	 */
95
-	public function getLimit(): int {
96
-		return $this->getArgument('limit');
97
-	}
92
+    /**
93
+     * @since 16.0.0
94
+     */
95
+    public function getLimit(): int {
96
+        return $this->getArgument('limit');
97
+    }
98 98
 
99 99
 }
Please login to merge, or discard this patch.