Completed
Pull Request — master (#4346)
by Lukas
18:14
created
core/Controller/LoginController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 	 * @return RedirectResponse
209 209
 	 */
210 210
 	public function tryLogin($user, $password, $redirect_url, $remember_login = false, $timezone = '', $timezone_offset = '') {
211
-		if(!is_string($user)) {
211
+		if (!is_string($user)) {
212 212
 			throw new \InvalidArgumentException('Username must be string');
213 213
 		}
214 214
 
215 215
 		// If the user is already logged in and the CSRF check does not pass then
216 216
 		// simply redirect the user to the correct page as required. This is the
217 217
 		// case when an user has already logged-in, in another tab.
218
-		if(!$this->request->passesCSRFCheck()) {
218
+		if (!$this->request->passesCSRFCheck()) {
219 219
 			return $this->generateRedirect($redirect_url);
220 220
 		}
221 221
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 				$user = $users[0]->getUID();
235 235
 				$loginResult = $this->userManager->checkPassword($user, $password);
236 236
 			} else {
237
-				$this->logger->warning('Login failed: \''. $user .'\' (Remote IP: \''. $this->request->getRemoteAddress(). '\')', ['app' => 'core']);
237
+				$this->logger->warning('Login failed: \''.$user.'\' (Remote IP: \''.$this->request->getRemoteAddress().'\')', ['app' => 'core']);
238 238
 			}
239 239
 		}
240 240
 		if ($loginResult === false) {
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		// TODO: remove password checks from above and let the user session handle failures
251 251
 		// requires https://github.com/owncloud/core/pull/24616
252 252
 		$this->userSession->completeLogin($loginResult, ['loginName' => $user, 'password' => $password]);
253
-		$this->userSession->createSessionToken($this->request, $loginResult->getUID(), $user, $password, (int)$remember_login);
253
+		$this->userSession->createSessionToken($this->request, $loginResult->getUID(), $user, $password, (int) $remember_login);
254 254
 
255 255
 		// User has successfully logged in, now remove the password reset link, when it is available
256 256
 		$this->config->deleteUserValue($loginResult->getUID(), 'core', 'lostpassword');
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/Security/BruteForceMiddleware.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	public function beforeController($controller, $methodName) {
62 62
 		parent::beforeController($controller, $methodName);
63 63
 
64
-		if($this->reflector->hasAnnotation('BruteForceProtection')) {
64
+		if ($this->reflector->hasAnnotation('BruteForceProtection')) {
65 65
 			$action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action');
66 66
 			$this->throttler->sleepDelay($this->request->getRemoteAddress(), $action);
67 67
 		}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * {@inheritDoc}
72 72
 	 */
73 73
 	public function afterController($controller, $methodName, Response $response) {
74
-		if($this->reflector->hasAnnotation('BruteForceProtection') && $response->isThrottled()) {
74
+		if ($this->reflector->hasAnnotation('BruteForceProtection') && $response->isThrottled()) {
75 75
 			$action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action');
76 76
 			$ip = $this->request->getRemoteAddress();
77 77
 			$this->throttler->sleepDelay($ip, $action);
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// security checks
146 146
 		$isPublicPage = $this->reflector->hasAnnotation('PublicPage');
147
-		if(!$isPublicPage) {
148
-			if(!$this->isLoggedIn) {
147
+		if (!$isPublicPage) {
148
+			if (!$this->isLoggedIn) {
149 149
 				throw new NotLoggedInException();
150 150
 			}
151 151
 
152
-			if(!$this->reflector->hasAnnotation('NoAdminRequired')) {
153
-				if(!$this->isAdminUser) {
152
+			if (!$this->reflector->hasAnnotation('NoAdminRequired')) {
153
+				if (!$this->isAdminUser) {
154 154
 					throw new NotAdminException();
155 155
 				}
156 156
 			}
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
 		}
165 165
 
166 166
 		// Check for strict cookie requirement
167
-		if($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) {
168
-			if(!$this->request->passesStrictCookieCheck()) {
167
+		if ($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) {
168
+			if (!$this->request->passesStrictCookieCheck()) {
169 169
 				throw new StrictCookieMissingException();
170 170
 			}
171 171
 		}
172 172
 		// CSRF check - also registers the CSRF token since the session may be closed later
173 173
 		Util::callRegister();
174
-		if(!$this->reflector->hasAnnotation('NoCSRFRequired')) {
174
+		if (!$this->reflector->hasAnnotation('NoCSRFRequired')) {
175 175
 			/*
176 176
 			 * Only allow the CSRF check to fail on OCS Requests. This kind of
177 177
 			 * hacks around that we have no full token auth in place yet and we
178 178
 			 * do want to offer CSRF checks for web requests.
179 179
 			 */
180
-			if(!$this->request->passesCSRFCheck() && !(
180
+			if (!$this->request->passesCSRFCheck() && !(
181 181
 					$controller instanceof OCSController &&
182 182
 					$this->request->getHeader('OCS-APIREQUEST') === 'true')) {
183 183
 				throw new CrossSiteRequestForgeryException();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		 * The getAppPath() check is here since components such as settings also use the AppFramework and
191 191
 		 * therefore won't pass this check.
192 192
 		 */
193
-		if(\OC_App::getAppPath($this->appName) !== false && !\OC_App::isEnabled($this->appName)) {
193
+		if (\OC_App::getAppPath($this->appName) !== false && !\OC_App::isEnabled($this->appName)) {
194 194
 			throw new AppNotEnabledException();
195 195
 		}
196 196
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		$defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy();
216 216
 		$defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy);
217 217
 
218
-		if($this->cspNonceManager->browserSupportsCspV3()) {
218
+		if ($this->cspNonceManager->browserSupportsCspV3()) {
219 219
 			$defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue());
220 220
 		}
221 221
 
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 	 * @return Response a Response object or null in case that the exception could not be handled
236 236
 	 */
237 237
 	public function afterException($controller, $methodName, \Exception $exception) {
238
-		if($exception instanceof SecurityException) {
239
-			if($exception instanceof StrictCookieMissingException) {
238
+		if ($exception instanceof SecurityException) {
239
+			if ($exception instanceof StrictCookieMissingException) {
240 240
 				return new RedirectResponse(\OC::$WEBROOT);
241 241
  			}
242
-			if (stripos($this->request->getHeader('Accept'),'html') === false) {
242
+			if (stripos($this->request->getHeader('Accept'), 'html') === false) {
243 243
 				$response = new JSONResponse(
244 244
 					array('message' => $exception->getMessage()),
245 245
 					$exception->getCode()
246 246
 				);
247 247
 			} else {
248
-				if($exception instanceof NotLoggedInException) {
248
+				if ($exception instanceof NotLoggedInException) {
249 249
 					$url = $this->urlGenerator->linkToRoute(
250 250
 						'core.login.showLoginForm',
251 251
 						[
Please login to merge, or discard this patch.
lib/private/AppFramework/DependencyInjection/DIContainer.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param array $urlParams
77 77
 	 * @param ServerContainer $server
78 78
 	 */
79
-	public function __construct($appName, $urlParams = array(), ServerContainer $server = null){
79
+	public function __construct($appName, $urlParams = array(), ServerContainer $server = null) {
80 80
 		parent::__construct();
81 81
 		$this['AppName'] = $appName;
82 82
 		$this['urlParams'] = $urlParams;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		/**
97 97
 		 * Core services
98 98
 		 */
99
-		$this->registerService(IOutput::class, function($c){
99
+		$this->registerService(IOutput::class, function($c) {
100 100
 			return new Output($this->getServer()->getWebRoot());
101 101
 		});
102 102
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			return $this->getServer()->getUserFolder();
105 105
 		});
106 106
 
107
-		$this->registerService(IAppData::class, function (SimpleContainer $c) {
107
+		$this->registerService(IAppData::class, function(SimpleContainer $c) {
108 108
 			return $this->getServer()->getAppDataDir($c->query('AppName'));
109 109
 		});
110 110
 
@@ -125,25 +125,25 @@  discard block
 block discarded – undo
125 125
 
126 126
 		$this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class);
127 127
 
128
-		$this->registerService(IServerContainer::class, function ($c) {
128
+		$this->registerService(IServerContainer::class, function($c) {
129 129
 			return $this->getServer();
130 130
 		});
131 131
 		$this->registerAlias('ServerContainer', IServerContainer::class);
132 132
 
133
-		$this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) {
133
+		$this->registerService(\OCP\WorkflowEngine\IManager::class, function($c) {
134 134
 			return $c->query('OCA\WorkflowEngine\Manager');
135 135
 		});
136 136
 
137
-		$this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) {
137
+		$this->registerService(\OCP\AppFramework\IAppContainer::class, function($c) {
138 138
 			return $c;
139 139
 		});
140 140
 
141 141
 		// commonly used attributes
142
-		$this->registerService('UserId', function ($c) {
142
+		$this->registerService('UserId', function($c) {
143 143
 			return $c->query('OCP\\IUserSession')->getSession()->get('user_id');
144 144
 		});
145 145
 
146
-		$this->registerService('WebRoot', function ($c) {
146
+		$this->registerService('WebRoot', function($c) {
147 147
 			return $c->query('ServerContainer')->getWebRoot();
148 148
 		});
149 149
 
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
 			return Util::getDefaultEmailAddress('no-reply');
152 152
 		});
153 153
 
154
-		$this->registerService('OC_Defaults', function ($c) {
154
+		$this->registerService('OC_Defaults', function($c) {
155 155
 			return $c->getServer()->getThemingDefaults();
156 156
 		});
157 157
 
158
-		$this->registerService('OCP\Encryption\IManager', function ($c) {
158
+		$this->registerService('OCP\Encryption\IManager', function($c) {
159 159
 			return $this->getServer()->getEncryptionManager();
160 160
 		});
161 161
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 			return $c->query(Validator::class);
164 164
 		});
165 165
 
166
-		$this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
166
+		$this->registerService(\OC\Security\IdentityProof\Manager::class, function($c) {
167 167
 			return new \OC\Security\IdentityProof\Manager(
168 168
 				$this->getServer()->getAppDataDir('identityproof'),
169 169
 				$this->getServer()->getCrypto()
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 		/**
174 174
 		 * App Framework APIs
175 175
 		 */
176
-		$this->registerService('API', function($c){
176
+		$this->registerService('API', function($c) {
177 177
 			$c->query('OCP\\ILogger')->debug(
178
-				'Accessing the API class is deprecated! Use the appropriate ' .
178
+				'Accessing the API class is deprecated! Use the appropriate '.
179 179
 				'services instead!'
180 180
 			);
181 181
 			return new API($c['AppName']);
182 182
 		});
183 183
 
184
-		$this->registerService('Protocol', function($c){
184
+		$this->registerService('Protocol', function($c) {
185 185
 			/** @var \OC\Server $server */
186 186
 			$server = $c->query('ServerContainer');
187 187
 			$protocol = $server->getRequest()->getHttpProtocol();
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 			);
270 270
 		});
271 271
 
272
-		$this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) {
272
+		$this->registerService('TwoFactorMiddleware', function(SimpleContainer $c) use ($app) {
273 273
 			$twoFactorManager = $c->getServer()->getTwoFactorAuthManager();
274 274
 			$userSession = $app->getServer()->getUserSession();
275 275
 			$session = $app->getServer()->getSession();
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 			return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request);
280 280
 		});
281 281
 
282
-		$this->registerService('OCSMiddleware', function (SimpleContainer $c) {
282
+		$this->registerService('OCSMiddleware', function(SimpleContainer $c) {
283 283
 			return new OCSMiddleware(
284 284
 				$c['Request']
285 285
 			);
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			$dispatcher->registerMiddleware($c['BruteForceMiddleware']);
296 296
 			$dispatcher->registerMiddleware($c['RateLimitingMiddleware']);
297 297
 
298
-			foreach($middleWares as $middleWare) {
298
+			foreach ($middleWares as $middleWare) {
299 299
 				$dispatcher->registerMiddleware($c[$middleWare]);
300 300
 			}
301 301
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	 * @return mixed
368 368
 	 */
369 369
 	function log($message, $level) {
370
-		switch($level){
370
+		switch ($level) {
371 371
 			case 'debug':
372 372
 				$level = \OCP\Util::DEBUG;
373 373
 				break;
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
 				return parent::query($name);
427 427
 			} else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) {
428 428
 				return parent::query($name);
429
-			} else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) {
429
+			} else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']).'\\') === 0) {
430 430
 				return parent::query($name);
431 431
 			}
432 432
 		}
433 433
 
434
-		throw new QueryException('Could not resolve ' . $name . '!' .
434
+		throw new QueryException('Could not resolve '.$name.'!'.
435 435
 			' Class can not be instantiated');
436 436
 	}
437 437
 }
Please login to merge, or discard this patch.