Skip to content

Commit

Permalink
better errors for mismatched authorization endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpk committed Feb 13, 2022
1 parent 46f5ac3 commit 9c0f3c1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/Provider/IndieAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@ public function redirect_indieauth(ServerRequestInterface $request, ResponseInte

$userlog->info('Entered URL ('.$_SESSION['expected_me'].') was different than resulting URL ('.$auth['me'].'), verifying authorization server');

if(!$newAuthorizationEndpoint) {
$userlog->warning('No authorization endpoint found', ['response' => $auth, 'expected' => $_SESSION['expected_me']]);
return $this->_userError($response, 'Error verifying the login attempt. Could not find an authorization endpoint at the profile URL returned (<b>'.$auth['me'].'</b>)');
}

if($_SESSION['login_request']['authorization_endpoint'] != $newAuthorizationEndpoint) {
$userlog->warning('IndieAuth user mismatch', ['response' => $auth, 'expected' => $_SESSION['expected_me']]);
return $this->_userError($response, 'It looks like a different user signed in. The user <b>'.$auth['me'].'</b> signed in, but we were expecting <b>'.$_SESSION['expected_me'].'</b>');
return $this->_userError($response, 'Error verifying the login attempt. The profile URL returned (<b>'.$auth['me'].'</b>) doesn\'t have the same authorization endpoint found at <b>'.$_SESSION['expected_me'].'</b>');
}
}

Expand Down

0 comments on commit 9c0f3c1

Please sign in to comment.