Commit 8a4adfd3 authored by Clément OUDOT's avatar Clément OUDOT

Configure Facebook user field (#1322)

parent 7eb24abe
......@@ -48,6 +48,7 @@ sub defaultValues {
'ext2fActivation' => 0,
'facebookAuthnLevel' => 1,
'facebookExportedVars' => {},
'facebookUserField' => 'id',
'failedLoginNumber' => 5,
'formTimeout' => 120,
'globalStorage' => 'Apache::Session::File',
......
......@@ -41,7 +41,7 @@ our $authParameters = {
customParams => [qw(customAuth customUserDB customPassword customRegister customAddParams)],
dbiParams => [qw(dbiAuthnLevel dbiExportedVars dbiAuthChain dbiAuthUser dbiAuthPassword dbiUserChain dbiUserUser dbiUserPassword dbiAuthTable dbiUserTable dbiAuthLoginCol dbiAuthPasswordCol dbiPasswordMailCol userPivot dbiAuthPasswordHash dbiDynamicHashEnabled dbiDynamicHashValidSchemes dbiDynamicHashValidSaltedSchemes dbiDynamicHashNewPasswordScheme)],
demoParams => [qw(demoExportedVars)],
facebookParams => [qw(facebookAuthnLevel facebookExportedVars facebookAppId facebookAppSecret)],
facebookParams => [qw(facebookAuthnLevel facebookExportedVars facebookAppId facebookAppSecret facebookUserField)],
kerberosParams => [qw(krbKeytab krbByJs krbAuthnLevel krbRemoveDomain)],
ldapParams => [qw(ldapAuthnLevel ldapExportedVars ldapServer ldapPort ldapBase managerDn managerPassword ldapTimeout ldapVersion ldapRaw LDAPFilter AuthLDAPFilter mailLDAPFilter ldapSearchDeref ldapGroupBase ldapGroupObjectClass ldapGroupAttributeName ldapGroupAttributeNameUser ldapGroupAttributeNameSearch ldapGroupRecursive ldapGroupAttributeNameGroup ldapPpolicyControl ldapSetPassword ldapChangePasswordAsUser ldapPwdEnc ldapUsePasswordResetAttribute ldapPasswordResetAttribute ldapPasswordResetAttributeValue ldapAllowResetExpiredPassword)],
linkedinParams => [qw(linkedInAuthnLevel linkedInClientID linkedInClientSecret linkedInFields linkedInUserField linkedInScope)],
......
......@@ -1083,6 +1083,10 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
'test' => qr/^[a-zA-Z][a-zA-Z0-9_:\-]*$/,
'type' => 'keyTextContainer'
},
'facebookUserField' => {
'default' => 'id',
'type' => 'text'
},
'failedLoginNumber' => {
'default' => 5,
'type' => 'int'
......
......@@ -1457,7 +1457,7 @@ sub attributes {
grep { $_ =~ /Undefined subroutine/ ? () : $_ }
split( /\n/, $@ ) );
return $err ? ( 1, "__badExpression__: $err" ) : (1);
}
}
},
documentation => 'Virtualhost headers',
flags => 'h',
......@@ -2633,6 +2633,7 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
default => {},
documentation => 'Facebook exported variables',
},
facebookUserField => { type => 'text', default => 'id' },
# Twitter
twitterAuthnLevel => {
......@@ -2640,9 +2641,9 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
default => 1,
documentation => 'Twitter authentication level',
},
twitterKey => { type => 'text', },
twitterSecret => { type => 'text', },
twitterAppName => { type => 'text', },
twitterKey => { type => 'text', },
twitterSecret => { type => 'text', },
twitterAppName => { type => 'text', },
twitterUserField => { type => 'text', default => 'screen_name' },
# LinkedIn
......
......@@ -203,7 +203,8 @@ sub tree {
help => 'authfacebook.html',
nodes => [
'facebookAuthnLevel', 'facebookExportedVars',
'facebookAppId', 'facebookAppSecret'
'facebookAppId', 'facebookAppSecret',
'facebookUserField'
]
},
{
......@@ -377,7 +378,8 @@ sub tree {
form => 'simpleInputContainer',
nodes => [
'twitterAuthnLevel', 'twitterKey',
'twitterSecret', 'twitterAppName', 'twitterUserField'
'twitterSecret', 'twitterAppName',
'twitterUserField'
]
},
{
......
......@@ -248,6 +248,7 @@
"facebookAuthnLevel":"مستوى إثبات الهوية",
"facebookExportedVars":"المتغيرات المصدرة",
"facebookParams":"معاييرفاسيبوك",
"facebookUserField":"Field containing user identifier",
"failedLoginNumber":"عدد عمليات تسجيل الدخول الفاشلة المسجلة",
"fileToUpload":"الملف الذي ستحمله",
"forbidden":"لست مخولا بعرض هذه الصفحة",
......
......@@ -248,6 +248,7 @@
"facebookAuthnLevel":"Authentication level",
"facebookExportedVars":"Exported variables",
"facebookParams":"Facebook parameters",
"facebookUserField":"Field containing user identifier",
"failedLoginNumber":"Number of registered failed logins",
"fileToUpload":"File to upload",
"forbidden":"You're not authorized to show this page",
......
......@@ -248,6 +248,7 @@
"facebookAuthnLevel":"Niveau d'authentification",
"facebookExportedVars":"Variables exportées",
"facebookParams":"Paramètres Facebook",
"facebookUserField":"Champ contenant l'identifiant de l'utilisateur",
"failedLoginNumber":"Nombre d'échecs de connexion mémorisés",
"fileToUpload":"Fichier à télécharger",
"forbidden":"Vous n'êtes pas autorisé à visualiser cette page",
......
......@@ -248,6 +248,7 @@
"facebookAuthnLevel":"Livello di autenticazione",
"facebookExportedVars":"Variabili esportate",
"facebookParams":"Parametri di Facebook",
"facebookUserField":"Field containing user identifier",
"failedLoginNumber":"Numero di login registrati non riusciti",
"fileToUpload":"File da caricare",
"forbidden":"Non sei autorizzato a mostrare questa pagina",
......
......@@ -248,6 +248,7 @@
"facebookAuthnLevel":"Mức xác thực",
"facebookExportedVars":"Biến đã được xuất",
"facebookParams":"Tham số Facebook",
"facebookUserField":"Field containing user identifier",
"failedLoginNumber":"Số lượt đăng nhập thất bại",
"fileToUpload":"Tập tin để tải lên",
"forbidden":"Bạn không được ủy quyền để hiển thị trang này",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -49,14 +49,13 @@ sub extractFormInfo {
$req->{sessionInfo}->{_facebookToken} = $access_token;
# Get mandatory fields (see https://developers.facebook.com/tools/explorer)
my @fields = ('id');
my @fields = ( $self->conf->{facebookUserField} );
# Search all wanted fields
push @fields,
map { /^(\w+)$/ ? ($1) : () }
values %{ $self->conf->{facebookExportedVars} };
# Look at wanted fields
if ( $self->p->getModule( $req, 'user' ) =~ /^Facebook/ ) {
push @fields,
map { /^(\w+)$/ ? ($1) : () }
values %{ $self->conf->{facebookExportedVars} };
}
my $datas;
# When a field is not granted, Facebook returns only an error
......@@ -86,13 +85,14 @@ sub extractFormInfo {
return PE_ERROR;
}
# Use id field to trace user
unless ( $datas->{id} ) {
# Field to trace user
unless ( $datas->{ $self->conf->{facebookUserField} } ) {
$self->logger->error('Unable to get Facebook id');
return PE_ERROR;
}
$req->user( $datas->{id} );
$req->user( $datas->{ $self->conf->{facebookUserField} } );
$req->datas->{_facebookDatas} = $datas;
$req->{sessionInfo}->{_facebookDatas} = $datas;
# Force redirection to avoid displaying Oauth datas
$req->mustRedirect(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment