Skip to content

Commit ccc90da

Browse files
authored
Merge pull request #1157 from nextcloud/enh/noid/state-mismatch-debug
Add warning log with more data when there is a state mismatch
2 parents a82a487 + 572688f commit ccc90da

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

lib/Controller/LoginController.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,16 +328,23 @@ public function code(string $state = '', string $code = '', string $scope = '',
328328
return $this->build403TemplateResponse($message, Http::STATUS_BAD_REQUEST, [], false);
329329
}
330330

331-
if ($this->session->get(self::STATE) !== $state) {
332-
$this->logger->debug('state does not match');
331+
$storedState = $this->session->get(self::STATE);
332+
333+
if ($storedState !== $state) {
334+
$this->logger->warning('state does not match', [
335+
'got' => $state,
336+
'expected' => $storedState,
337+
'state_exists_in_session' => $this->session->exists(self::STATE),
338+
]);
333339

334340
$message = $this->l10n->t('The received state does not match the expected value.');
335341
if ($this->isDebugModeEnabled()) {
336342
$responseData = [
337343
'error' => 'invalid_state',
338344
'error_description' => $message,
339345
'got' => $state,
340-
'expected' => $this->session->get(self::STATE),
346+
'expected' => $storedState,
347+
'state_exists_in_session' => $this->session->exists(self::STATE),
341348
];
342349
return new JSONResponse($responseData, Http::STATUS_FORBIDDEN);
343350
}

0 commit comments

Comments
 (0)