Skip to content
Snippets Groups Projects
Commit 24db2740 authored by Olav Morken's avatar Olav Morken
Browse files

authtwitter: throw UserAborted error when the user cancels authentication.

Thanks to Andjelko Horvat for implementing this.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2775 44740490-163a-0410-bde0-09ae8108e29a
parent ba5cbafd
No related branches found
No related tags found
No related merge requests found
...@@ -10,8 +10,8 @@ $session = SimpleSAML_Session::getInstance(); ...@@ -10,8 +10,8 @@ $session = SimpleSAML_Session::getInstance();
$oauthState = $session->getData('oauth', 'oauth'); $oauthState = $session->getData('oauth', 'oauth');
if (empty($oauthState)) throw new Exception('Could not load oauthstate'); if (empty($oauthState)) throw new SimpleSAML_Error_Exception('Could not load oauthstate');
if (empty($oauthState['stateid'])) throw new Exception('Could not load oauthstate:stateid'); if (empty($oauthState['stateid'])) throw new SimpleSAML_Error_Exception('Could not load oauthstate:stateid');
$stateId = $oauthState['stateid']; $stateId = $oauthState['stateid'];
...@@ -20,25 +20,23 @@ $stateId = $oauthState['stateid']; ...@@ -20,25 +20,23 @@ $stateId = $oauthState['stateid'];
$state = SimpleSAML_Auth_State::loadState($stateId, sspmod_authtwitter_Auth_Source_Twitter::STAGE_INIT); $state = SimpleSAML_Auth_State::loadState($stateId, sspmod_authtwitter_Auth_Source_Twitter::STAGE_INIT);
$state['requestToken'] = $oauthState['requestToken']; $state['requestToken'] = $oauthState['requestToken'];
/* Find authentication source. */ /* Find authentication source. */
assert('array_key_exists(sspmod_authtwitter_Auth_Source_Twitter::AUTHID, $state)'); if (!array_key_exists(sspmod_authtwitter_Auth_Source_Twitter::AUTHID, $state)) {
throw new SimpleSAML_Error_Exception('No data in state for ' . sspmod_authtwitter_Auth_Source_Twitter::AUTHID);
}
$sourceId = $state[sspmod_authtwitter_Auth_Source_Twitter::AUTHID]; $sourceId = $state[sspmod_authtwitter_Auth_Source_Twitter::AUTHID];
$source = SimpleSAML_Auth_Source::getById($sourceId); $source = SimpleSAML_Auth_Source::getById($sourceId);
if ($source === NULL) { if ($source === NULL) {
throw new Exception('Could not find authentication source with id ' . $sourceId); throw new SimpleSAML_Error_Exception('Could not find authentication source with id ' . $sourceId);
} }
if (array_key_exists('denied', $_REQUEST)) {
SimpleSAML_Auth_State::throwException($state, new SimpleSAML_Error_UserAborted());
}
$config = SimpleSAML_Configuration::getInstance(); $config = SimpleSAML_Configuration::getInstance();
$source->finalStep($state); $source->finalStep($state);
SimpleSAML_Auth_Source::completeAuth($state); SimpleSAML_Auth_Source::completeAuth($state);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment