@@ -54,6 +54,6 @@ |
||
| 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; ?> |
@@ -62,7 +62,7 @@ |
||
| 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 | |
@@ -170,12 +170,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | <td><?php p($client->getName()); ?></td> |
| 51 | 51 | <td><?php p($client->getRedirectUri()); ?></td> |
| 52 | 52 | <td><code><?php p($client->getClientIdentifier()); ?></code></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> |
|
| 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']) ?>" /> |
@@ -118,7 +118,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | $clientName = $this->getClientName(); |
| 275 | 275 | $oAuthClient = false; |
| 276 | - if($clientIdentifier !== '') { |
|
| 276 | + if ($clientIdentifier !== '') { |
|
| 277 | 277 | $client = $this->clientMapper->getByIdentifier($clientIdentifier); |
| 278 | 278 | $clientName = $client->getName(); |
| 279 | 279 | $oAuthClient = true; |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | IToken::DO_NOT_REMEMBER |
| 292 | 292 | ); |
| 293 | 293 | |
| 294 | - if($oAuthClient) { |
|
| 294 | + if ($oAuthClient) { |
|
| 295 | 295 | $client = $this->clientMapper->getByIdentifier($clientIdentifier); |
| 296 | 296 | |
| 297 | 297 | $code = $this->random->generate(128); |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | urlencode($code) |
| 310 | 310 | ); |
| 311 | 311 | } else { |
| 312 | - $redirectUri = 'nc://login/server:' . $this->request->getServerHost() . '&user:' . urlencode($loginName) . '&password:' . urlencode($token); |
|
| 312 | + $redirectUri = 'nc://login/server:'.$this->request->getServerHost().'&user:'.urlencode($loginName).'&password:'.urlencode($token); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | return new Http\RedirectResponse($redirectUri); |