diff --git a/config-templates/authsources.php b/config-templates/authsources.php index af52cfb6e748bbf5af1625dbc01060697f74f2a7..2eedc80fc85024b290715709d9b3661e63b1295a 100644 --- a/config-templates/authsources.php +++ b/config-templates/authsources.php @@ -189,6 +189,10 @@ $config = array( 'authtwitter:Twitter', 'key' => 'xxxxxxxxxxxxxxxx', 'secret' => 'xxxxxxxxxxxxxxxx', + + // Forces the user to enter their credentials to ensure the correct users account is authorized. + // Details: https://dev.twitter.com/docs/api/1/get/oauth/authenticate + 'force_login' => FALSE, ), */ diff --git a/modules/authtwitter/lib/Auth/Source/Twitter.php b/modules/authtwitter/lib/Auth/Source/Twitter.php index 8ee8c7d97c92ccfeafd5f06596acac27637c45bd..72aa93283a6c0cb8b31800fc423d00777a24cab2 100644 --- a/modules/authtwitter/lib/Auth/Source/Twitter.php +++ b/modules/authtwitter/lib/Auth/Source/Twitter.php @@ -23,6 +23,7 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { private $key; private $secret; + private $force_login; /** @@ -42,6 +43,7 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { $this->key = $configObject->getString('key'); $this->secret = $configObject->getString('secret'); + $this->force_login = $configObject->getBoolean('force_login', FALSE); } @@ -69,7 +71,11 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { SimpleSAML_Auth_State::saveState($state, self::STAGE_INIT); // Authorize the request token - $consumer->getAuthorizeRequest('https://api.twitter.com/oauth/authenticate', $requestToken); + $url = 'https://api.twitter.com/oauth/authenticate'; + if ($this->force_login) { + $url = SimpleSAML_Utilities::addURLparameter($url, array('force_login' => 'true')); + } + $consumer->getAuthorizeRequest($url, $requestToken); }