Skip to content
Snippets Groups Projects
Unverified Commit 03e2b7c0 authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

Missing declaration + PSR-2 + phpdoc

parent 207249ec
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
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