diff --git a/modules/authtwitter/lib/Auth/Source/Twitter.php b/modules/authtwitter/lib/Auth/Source/Twitter.php index 9be9fd90d72ff01fb99e9ba074350f3d3b8341e6..2b5d68d9328aa4dacbe5ec64e0ee191b54539da9 100644 --- a/modules/authtwitter/lib/Auth/Source/Twitter.php +++ b/modules/authtwitter/lib/Auth/Source/Twitter.php @@ -8,8 +8,8 @@ require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/oauth/lib * @author Andreas Ă…kre Solberg, UNINETT AS. * @package SimpleSAMLphp */ -class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { - +class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source +{ /** * The string used to identify our states. */ @@ -20,10 +20,25 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { */ const AUTHID = 'twitter:AuthId'; + /** + * @var string + */ private $key; - private $secret; + + /** + * @var string + */ + private $secret; + + /** + * @var bool + */ private $force_login; + /** + * @var bool + */ + private $include_email; /** * Constructor for this authentication source. @@ -31,19 +46,20 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { * @param array $info Information about this authentication source. * @param array $config Configuration. */ - public function __construct($info, $config) { + public function __construct($info, $config) + { assert(is_array($info)); assert(is_array($config)); // Call the parent constructor first, as required by the interface parent::__construct($info, $config); - $configObject = SimpleSAML_Configuration::loadFromArray($config, 'authsources[' . var_export($this->authId, TRUE) . ']'); + $configObject = SimpleSAML_Configuration::loadFromArray($config, 'authsources[' . var_export($this->authId, true) . ']'); $this->key = $configObject->getString('key'); $this->secret = $configObject->getString('secret'); - $this->force_login = $configObject->getBoolean('force_login', FALSE); - $this->include_email = $configObject->getBoolean('include_email', FALSE); + $this->force_login = $configObject->getBoolean('force_login', false); + $this->include_email = $configObject->getBoolean('include_email', false); } @@ -52,7 +68,8 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { * * @param array &$state Information about the current authentication. */ - public function authenticate(&$state) { + public function authenticate(&$state) + { assert(is_array($state)); // We are going to need the authId in order to retrieve this authentication source later @@ -79,7 +96,8 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { } - public function finalStep(&$state) { + public function finalStep(&$state) + { $requestToken = $state['authtwitter:authdata:requestToken']; $parameters = array(); @@ -116,9 +134,10 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { } $attributes = array(); - foreach($userdata AS $key => $value) { - if (is_string($value)) + foreach ($userdata as $key => $value) { + if (is_string($value)) { $attributes['twitter.' . $key] = array((string)$value); + } } $attributes['twitter_at_screen_name'] = array('@' . $userdata['screen_name']); @@ -127,5 +146,4 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source { $state['Attributes'] = $attributes; } - }