Completed
Pull Request — master (#4704)
by Björn
16:36
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.
core/Controller/ClientFlowLoginController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	private function isValidToken($stateToken) {
120 120
 		$currentToken = $this->session->get(self::stateName);
121
-		if(!is_string($stateToken) || !is_string($currentToken)) {
121
+		if (!is_string($stateToken) || !is_string($currentToken)) {
122 122
 			return false;
123 123
 		}
124 124
 		return hash_equals($currentToken, $stateToken);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
 		$clientName = $this->getClientName();
157 157
 		$client = null;
158
-		if($clientIdentifier !== '') {
158
+		if ($clientIdentifier !== '') {
159 159
 			$client = $this->clientMapper->getByIdentifier($clientIdentifier);
160 160
 			$clientName = $client->getName();
161 161
 		}
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	public function redirectPage($stateToken = '',
212 212
 								 $clientIdentifier = '',
213 213
 								 $oauthState = '') {
214
-		if(!$this->isValidToken($stateToken)) {
214
+		if (!$this->isValidToken($stateToken)) {
215 215
 			return $this->stateTokenForbiddenResponse();
216 216
 		}
217 217
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 										$clientIdentifier = '',
243 243
 										$state = '',
244 244
 										$oauthState = '') {
245
-		if(!$this->isValidToken($stateToken)) {
245
+		if (!$this->isValidToken($stateToken)) {
246 246
 			$this->session->remove(self::stateName);
247 247
 			return $this->stateTokenForbiddenResponse();
248 248
 		}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 			IToken::DO_NOT_REMEMBER
284 284
 		);
285 285
 
286
-		if($clientIdentifier !== '') {
286
+		if ($clientIdentifier !== '') {
287 287
 			$client = $this->clientMapper->getByIdentifier($clientIdentifier);
288 288
 
289 289
 			$code = $this->random->generate(128);
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 				urlencode($code)
302 302
 			);
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.
apps/oauth2/lib/Controller/LoginRedirectorController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 							  $state) {
63 63
 		$client = $this->clientMapper->getByIdentifier($client_id);
64 64
 
65
-		if($client->getRedirectUri() !== $redirect_uri) {
65
+		if ($client->getRedirectUri() !== $redirect_uri) {
66 66
 			throw new \Exception('Redirect URI does not match');
67 67
 		}
68 68
 
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.
apps/oauth2/templates/admin.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@
 block discarded – undo
49 49
 			<tr>
50 50
 				<td><?php p($client->getName()); ?></td>
51 51
 				<td><?php p($client->getRedirectUri()); ?></td>
52
-				<td data-value="<?php p($client->getClientIdentifier()); ?>"><code>****</code><img class='show-oauth-credentials' src="<?php p($urlGenerator->imagePath('core', 'actions/toggle.svg'));?>"/></td>
53
-				<td data-value="<?php p($client->getSecret()); ?>"><code>****</code><img class='show-oauth-credentials' src="<?php p($urlGenerator->imagePath('core', 'actions/toggle.svg'));?>"/></td>
52
+				<td data-value="<?php p($client->getClientIdentifier()); ?>"><code>****</code><img class='show-oauth-credentials' src="<?php p($urlGenerator->imagePath('core', 'actions/toggle.svg')); ?>"/></td>
53
+				<td data-value="<?php p($client->getSecret()); ?>"><code>****</code><img class='show-oauth-credentials' src="<?php p($urlGenerator->imagePath('core', 'actions/toggle.svg')); ?>"/></td>
54 54
 				<td>
55 55
 					<form id="form-inline" class="delete" action="<?php p($urlGenerator->linkToRoute('oauth2.Settings.deleteClient', ['id' => $client->getId()])); ?>" method="POST">
56 56
 						<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
Please login to merge, or discard this patch.