Passed
Push — master ( ec7e83...51197a )
by Roeland
10:19 queued 12s
created
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
 
131 131
 		// security checks
132 132
 		$isPublicPage = $this->reflector->hasAnnotation('PublicPage');
133
-		if(!$isPublicPage) {
134
-			if(!$this->isLoggedIn) {
133
+		if (!$isPublicPage) {
134
+			if (!$this->isLoggedIn) {
135 135
 				throw new NotLoggedInException();
136 136
 			}
137 137
 
138
-			if($this->reflector->hasAnnotation('SubAdminRequired')
138
+			if ($this->reflector->hasAnnotation('SubAdminRequired')
139 139
 				&& !$this->isSubAdmin
140 140
 				&& !$this->isAdminUser) {
141 141
 				throw new NotAdminException($this->l10n->t('Logged in user must be an admin or sub admin'));
142 142
 			}
143
-			if(!$this->reflector->hasAnnotation('SubAdminRequired')
143
+			if (!$this->reflector->hasAnnotation('SubAdminRequired')
144 144
 				&& !$this->reflector->hasAnnotation('NoAdminRequired')
145 145
 				&& !$this->isAdminUser) {
146 146
 				throw new NotAdminException($this->l10n->t('Logged in user must be an admin'));
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 		}
149 149
 
150 150
 		// Check for strict cookie requirement
151
-		if($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) {
152
-			if(!$this->request->passesStrictCookieCheck()) {
151
+		if ($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) {
152
+			if (!$this->request->passesStrictCookieCheck()) {
153 153
 				throw new StrictCookieMissingException();
154 154
 			}
155 155
 		}
156 156
 		// CSRF check - also registers the CSRF token since the session may be closed later
157 157
 		Util::callRegister();
158
-		if(!$this->reflector->hasAnnotation('NoCSRFRequired')) {
158
+		if (!$this->reflector->hasAnnotation('NoCSRFRequired')) {
159 159
 			/*
160 160
 			 * Only allow the CSRF check to fail on OCS Requests. This kind of
161 161
 			 * hacks around that we have no full token auth in place yet and we
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			 * Additionally we allow Bearer authenticated requests to pass on OCS routes.
165 165
 			 * This allows oauth apps (e.g. moodle) to use the OCS endpoints
166 166
 			 */
167
-			if(!$this->request->passesCSRFCheck() && !(
167
+			if (!$this->request->passesCSRFCheck() && !(
168 168
 					$controller instanceof OCSController && (
169 169
 						$this->request->getHeader('OCS-APIREQUEST') === 'true' ||
170 170
 						strpos($this->request->getHeader('Authorization'), 'Bearer ') === 0
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
 	 * @return Response a Response object or null in case that the exception could not be handled
203 203
 	 */
204 204
 	public function afterException($controller, $methodName, \Exception $exception): Response {
205
-		if($exception instanceof SecurityException) {
206
-			if($exception instanceof StrictCookieMissingException) {
205
+		if ($exception instanceof SecurityException) {
206
+			if ($exception instanceof StrictCookieMissingException) {
207 207
 				return new RedirectResponse(\OC::$WEBROOT);
208 208
  			}
209
-			if (stripos($this->request->getHeader('Accept'),'html') === false) {
209
+			if (stripos($this->request->getHeader('Accept'), 'html') === false) {
210 210
 				$response = new JSONResponse(
211 211
 					['message' => $exception->getMessage()],
212 212
 					$exception->getCode()
213 213
 				);
214 214
 			} else {
215
-				if($exception instanceof NotLoggedInException) {
215
+				if ($exception instanceof NotLoggedInException) {
216 216
 					$params = [];
217 217
 					if (isset($this->request->server['REQUEST_URI'])) {
218 218
 						$params['redirect_url'] = $this->request->server['REQUEST_URI'];
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/Security/CSPMiddleware.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
 		$defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy();
70 70
 		$defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy);
71 71
 
72
-		if($this->cspNonceManager->browserSupportsCspV3()) {
72
+		if ($this->cspNonceManager->browserSupportsCspV3()) {
73 73
 			$defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue());
74 74
 		}
75 75
 
Please login to merge, or discard this patch.