Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
9a1d06cb
Unverified
Commit
9a1d06cb
authored
8 years ago
by
Nicolas Liampotis
Browse files
Options
Downloads
Patches
Plain Diff
Fix issue with Facebook authentication retrieving only user id and name
parent
93821de4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config-templates/authsources.php
+4
-0
4 additions, 0 deletions
config-templates/authsources.php
modules/authfacebook/lib/Auth/Source/Facebook.php
+19
-3
19 additions, 3 deletions
modules/authfacebook/lib/Auth/Source/Facebook.php
with
23 additions
and
3 deletions
config-templates/authsources.php
+
4
−
0
View file @
9a1d06cb
...
...
@@ -201,6 +201,10 @@ $config = array(
// which additional data permissions to request from user
// see http://developers.facebook.com/docs/authentication/permissions/ for the full list
// 'req_perms' => 'email,user_birthday',
// Which additional user profile fields to request.
// When empty, only the app-specific user id and name will be returned
// See https://developers.facebook.com/docs/graph-api/reference/v2.6/user for the full list
// 'user_fields' => 'email,birthday,third_party_id,name,first_name,last_name',
),
*/
...
...
This diff is collapsed.
Click to expand it.
modules/authfacebook/lib/Auth/Source/Facebook.php
+
19
−
3
View file @
9a1d06cb
...
...
@@ -39,6 +39,21 @@ class sspmod_authfacebook_Auth_Source_Facebook extends SimpleSAML_Auth_Source {
private
$req_perms
;
/**
* A comma-separated list of user profile fields to request.
*
* Note that some user fields require appropriate permissions. For
* example, to retrieve the user's primary email address, "email" must
* be specified in both the req_perms and the user_fields parameter.
*
* When empty, only the app-specific user id and name will be returned.
*
* See the Graph API specification for all available user fields:
* https://developers.facebook.com/docs/graph-api/reference/v2.6/user
*/
private
$user_fields
;
/**
* Constructor for this authentication source.
*
...
...
@@ -57,6 +72,7 @@ class sspmod_authfacebook_Auth_Source_Facebook extends SimpleSAML_Auth_Source {
$this
->
api_key
=
$cfgParse
->
getString
(
'api_key'
);
$this
->
secret
=
$cfgParse
->
getString
(
'secret'
);
$this
->
req_perms
=
$cfgParse
->
getString
(
'req_perms'
,
NULL
);
$this
->
user_fields
=
$cfgParse
->
getString
(
'user_fields'
,
NULL
);
}
...
...
@@ -91,7 +107,7 @@ class sspmod_authfacebook_Auth_Source_Facebook extends SimpleSAML_Auth_Source {
if
(
isset
(
$uid
)
&&
$uid
)
{
try
{
$info
=
$facebook
->
api
(
"/"
.
$uid
);
$info
=
$facebook
->
api
(
"/"
.
$uid
.
(
$this
->
user_fields
?
"?fields="
.
$this
->
user_fields
:
""
)
);
}
catch
(
FacebookApiException
$e
)
{
throw
new
SimpleSAML_Error_AuthSource
(
$this
->
authId
,
'Error getting user profile.'
,
$e
);
}
...
...
@@ -108,8 +124,8 @@ class sspmod_authfacebook_Auth_Source_Facebook extends SimpleSAML_Auth_Source {
}
}
if
(
array_key_exists
(
'
username
'
,
$info
))
{
$attributes
[
'facebook_user'
]
=
array
(
$info
[
'
username
'
]
.
'@facebook.com'
);
if
(
array_key_exists
(
'
third_party_id
'
,
$info
))
{
$attributes
[
'facebook_user'
]
=
array
(
$info
[
'
third_party_id
'
]
.
'@facebook.com'
);
}
else
{
$attributes
[
'facebook_user'
]
=
array
(
$uid
.
'@facebook.com'
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment