summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--attributemap/facebook2name.php21
-rw-r--r--modules/authfacebook/extlibinc/facebook.php1
-rw-r--r--modules/authfacebook/lib/Auth/Source/Facebook.php29
3 files changed, 41 insertions, 10 deletions
diff --git a/attributemap/facebook2name.php b/attributemap/facebook2name.php
new file mode 100644
index 0000000..eb3f7a1
--- /dev/null
+++ b/attributemap/facebook2name.php
@@ -0,0 +1,21 @@
+<?php
+$attributemap = array(
+
+ // Generated Facebook Attributes
+ 'facebook_user' => 'eduPersonPrincipalName', // username OR uid @ facebook.com
+ 'facebook_targetedID' => 'eduPersonTargetedID', // http://facebook.com!uid
+ 'facebook_cn' => 'cn', // duplicate of displayName
+
+ // Attributes Returned by Facebook
+ 'facebook.first_name' => 'givenName',
+ 'facebook.last_name' => 'sn',
+ 'facebook.name' => 'displayName', // or 'cn'
+ 'facebook.email' => 'mail',
+ //'facebook.pic' => 'jpegPhoto', // URL not image data
+ //'facebook.pic_square' => 'jpegPhoto', // URL not image data
+ 'facebook.username' => 'uid', // facebook username (maybe blank)
+ //'facebook.uid' => 'uid', // numeric facebook user id
+ 'facebook.profile_url' => 'labeledURI',
+ 'facebook.locale' => 'preferredLanguage',
+ 'facebook.about_me' => 'description',
+);
diff --git a/modules/authfacebook/extlibinc/facebook.php b/modules/authfacebook/extlibinc/facebook.php
index 428b215..fd381ec 100644
--- a/modules/authfacebook/extlibinc/facebook.php
+++ b/modules/authfacebook/extlibinc/facebook.php
@@ -217,6 +217,7 @@ class Facebook {
public function get_login_url($next, $canvas) {
return self::get_facebook_url().'/login.php?v=1.0&api_key=' . $this->api_key .
($next ? '&next=' . urlencode($next) : '') .
+ '&req_perms=email' .
($canvas ? '&canvas' : '');
}
diff --git a/modules/authfacebook/lib/Auth/Source/Facebook.php b/modules/authfacebook/lib/Auth/Source/Facebook.php
index 69e4665..aa08a65 100644
--- a/modules/authfacebook/lib/Auth/Source/Facebook.php
+++ b/modules/authfacebook/lib/Auth/Source/Facebook.php
@@ -70,23 +70,32 @@ class sspmod_authfacebook_Auth_Source_Facebook extends SimpleSAML_Auth_Source {
SimpleSAML_Logger::debug('facebook auth state id = ' . $stateID);
$facebook = new Facebook($this->api_key, $this->secret);
- $u = $facebook->require_login($stateID);
+ $u = $facebook->require_login(SimpleSAML_Module::getModuleUrl('authfacebook') . '/linkback.php?next=' . $stateID);
# http://developers.facebook.com/documentation.php?v=1.0&method=users.getInfo
/* Causes an notice / warning...
if ($facebook->api_client->error_code) {
throw new Exception('Unable to load profile from facebook');
}
*/
- $info = $facebook->api_client->users_getInfo($u, array('first_name', 'last_name'));
- $fullname = $info[0]['first_name'] .' '. $info[0]['last_name'];
+ // http://developers.facebook.com/docs/reference/rest/users.getInfo
+ $info = $facebook->api_client->users_getInfo($u, array('uid', 'first_name', 'middle_name', 'last_name', 'name', 'locale', 'current_location', 'affiliations', 'pic_square', 'profile_url', 'sex', 'email', 'pic', 'username', 'about_me', 'status', 'profile_blurb'));
- $attributes = array(
- 'sn' => array($info[0]['last_name']),
- 'givenName' => array($info[0]['first_name']),
- 'cn' => array($info[0]['first_name'] .' '. $info[0]['last_name']),
- 'uid' => array($u),
- 'eduPersonPrincipalName' => array('facebook:' . $u),
- );
+ $attributes = array();
+ foreach($info[0] AS $key => $value) {
+ if (is_string($value) && !empty($value))
+ $attributes['facebook.' . $key] = array((string)$value);
+ }
+
+ if (array_key_exists('username', $info[0]) )
+ $attributes['facebook_user'] = array($info[0]['username'] . '@facebook.com');
+ else
+ $attributes['facebook_user'] = array($u . '@facebook.com');
+
+ $attributes['facebook_targetedID'] = array('http://facebook.com!' . $u);
+ $attributes['facebook_cn'] = array($info[0]['name']);
+
+ SimpleSAML_Logger::debug('Facebook Returned Attributes: '. implode(", ",array_keys($attributes)));
+
$state['Attributes'] = $attributes;
}