Completed
Pull Request — master (#4704)
by Lukas
42:37 queued 12:53
created
core/templates/loginflow/authpicker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,6 +54,6 @@
 block discarded – undo
54 54
 	</fieldset>
55 55
 </div>
56 56
 
57
-<?php if(empty($_['oauthState'])): ?>
57
+<?php if (empty($_['oauthState'])): ?>
58 58
 <a id="app-token-login" class="warning" href="#"><?php p($l->t('Alternative login using app token')) ?></a>
59 59
 <?php endif; ?>
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Auth.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	private function requiresCSRFCheck() {
172 172
 		// GET requires no check at all
173
-		if($this->request->getMethod() === 'GET') {
173
+		if ($this->request->getMethod() === 'GET') {
174 174
 			return false;
175 175
 		}
176 176
 
177 177
 		// Official Nextcloud clients require no checks
178
-		if($this->request->isUserAgent([
178
+		if ($this->request->isUserAgent([
179 179
 			IRequest::USER_AGENT_CLIENT_DESKTOP,
180 180
 			IRequest::USER_AGENT_CLIENT_ANDROID,
181 181
 			IRequest::USER_AGENT_CLIENT_IOS,
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 		}
185 185
 
186 186
 		// If not logged-in no check is required
187
-		if(!$this->userSession->isLoggedIn()) {
187
+		if (!$this->userSession->isLoggedIn()) {
188 188
 			return false;
189 189
 		}
190 190
 
191 191
 		// POST always requires a check
192
-		if($this->request->getMethod() === 'POST') {
192
+		if ($this->request->getMethod() === 'POST') {
193 193
 			return true;
194 194
 		}
195 195
 
196 196
 		// If logged-in AND DAV authenticated no check is required
197
-		if($this->userSession->isLoggedIn() &&
197
+		if ($this->userSession->isLoggedIn() &&
198 198
 			$this->isDavAuthenticated($this->userSession->getUser()->getUID())) {
199 199
 			return false;
200 200
 		}
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
 
214 214
 		$authHeader = $request->getHeader('Authorization');
215 215
 		if (strpos($authHeader, 'Bearer ') !== false) {
216
-			if($this->userSession->tryTokenLogin($this->request)) {
216
+			if ($this->userSession->tryTokenLogin($this->request)) {
217 217
 				$this->session->set(self::DAV_AUTHENTICATED, $this->userSession->getUser()->getUID());
218 218
 				$user = $this->userSession->getUser()->getUID();
219 219
 				\OC_Util::setupFS($user);
220 220
 				$this->currentUser = $user;
221 221
 				$this->session->close();
222
-				return [true, $this->principalPrefix . $user];
222
+				return [true, $this->principalPrefix.$user];
223 223
 			}
224 224
 		}
225 225
 
226
-		if(!$this->request->passesCSRFCheck() &&
226
+		if (!$this->request->passesCSRFCheck() &&
227 227
 			$this->requiresCSRFCheck()) {
228 228
 			// In case of a fail with POST we need to recheck the credentials
229
-			if($this->request->getMethod() === 'POST') {
229
+			if ($this->request->getMethod() === 'POST') {
230 230
 				$forcedLogout = true;
231 231
 			} else {
232 232
 				$response->setStatus(401);
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 			}
235 235
 		}
236 236
 
237
-		if($forcedLogout) {
237
+		if ($forcedLogout) {
238 238
 			$this->userSession->logout();
239 239
 		} else {
240
-			if($this->twoFactorManager->needsSecondFactor($this->userSession->getUser())) {
240
+			if ($this->twoFactorManager->needsSecondFactor($this->userSession->getUser())) {
241 241
 				throw new \Sabre\DAV\Exception\NotAuthenticated('2FA challenge not passed.');
242 242
 			}
243 243
 			if (\OC_User::handleApacheAuth() ||
@@ -250,19 +250,19 @@  discard block
 block discarded – undo
250 250
 				\OC_Util::setupFS($user);
251 251
 				$this->currentUser = $user;
252 252
 				$this->session->close();
253
-				return [true, $this->principalPrefix . $user];
253
+				return [true, $this->principalPrefix.$user];
254 254
 			}
255 255
 		}
256 256
 
257 257
 		if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With')))) {
258 258
 			// do not re-authenticate over ajax, use dummy auth name to prevent browser popup
259
-			$response->addHeader('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"');
259
+			$response->addHeader('WWW-Authenticate', 'DummyBasic realm="'.$this->realm.'"');
260 260
 			$response->setStatus(401);
261 261
 			throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls');
262 262
 		}
263 263
 
264 264
 		$data = parent::check($request, $response);
265
-		if($data[0] === true) {
265
+		if ($data[0] === true) {
266 266
 			$startPos = strrpos($data[1], '/') + 1;
267 267
 			$user = $this->userSession->getUser()->getUID();
268 268
 			$data[1] = substr_replace($data[1], $user, $startPos);
Please login to merge, or discard this patch.
core/Controller/ClientFlowLoginController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	private function isValidToken($stateToken) {
121 121
 		$currentToken = $this->session->get(self::stateName);
122
-		if(!is_string($stateToken) || !is_string($currentToken)) {
122
+		if (!is_string($stateToken) || !is_string($currentToken)) {
123 123
 			return false;
124 124
 		}
125 125
 		return hash_equals($currentToken, $stateToken);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	public function showAuthPickerPage($clientIdentifier = '') {
154 154
 		$clientName = $this->getClientName();
155 155
 		$client = null;
156
-		if($clientIdentifier !== '') {
156
+		if ($clientIdentifier !== '') {
157 157
 			$client = $this->clientMapper->getByIdentifier($clientIdentifier);
158 158
 			$clientName = $client->getName();
159 159
 		}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	public function redirectPage($stateToken = '',
211 211
 								 $clientIdentifier = '') {
212
-		if(!$this->isValidToken($stateToken)) {
212
+		if (!$this->isValidToken($stateToken)) {
213 213
 			return $this->stateTokenForbiddenResponse();
214 214
 		}
215 215
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	public function generateAppPassword($stateToken,
238 238
 										$clientIdentifier = '') {
239
-		if(!$this->isValidToken($stateToken)) {
239
+		if (!$this->isValidToken($stateToken)) {
240 240
 			$this->session->remove(self::stateName);
241 241
 			return $this->stateTokenForbiddenResponse();
242 242
 		}
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
 		$clientName = $this->getClientName();
269 269
 		$client = false;
270
-		if($clientIdentifier !== '') {
270
+		if ($clientIdentifier !== '') {
271 271
 			$client = $this->clientMapper->getByIdentifier($clientIdentifier);
272 272
 			$clientName = $client->getName();
273 273
 		}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 			IToken::DO_NOT_REMEMBER
285 285
 		);
286 286
 
287
-		if($client) {
287
+		if ($client) {
288 288
 			$code = $this->random->generate(128);
289 289
 			$accessToken = new AccessToken();
290 290
 			$accessToken->setClientId($client->getId());
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 			);
302 302
 			$this->session->remove('oauth.state');
303 303
 		} else {
304
-			$redirectUri = 'nc://login/server:' . $this->request->getServerHost() . '&user:' . urlencode($loginName) . '&password:' . urlencode($token);
304
+			$redirectUri = 'nc://login/server:'.$this->request->getServerHost().'&user:'.urlencode($loginName).'&password:'.urlencode($token);
305 305
 		}
306 306
 
307 307
 		return new Http\RedirectResponse($redirectUri);
Please login to merge, or discard this patch.