| 1 |
Facebook |
| 2 |
======== |
| 3 |
|
| 4 |
============== ===== ======== |
| 5 |
Authentication Users Password |
| 6 |
============== ===== ======== |
| 7 |
✔ ✔ |
| 8 |
============== ===== ======== |
| 9 |
|
| 10 |
Presentation |
| 11 |
------------ |
| 12 |
|
| 13 |
`Facebook <http://facebook.com>`__ is a famous social network service. |
| 14 |
Facebook uses `OAuth2 <http://en.wikipedia.org/wiki/OAuth2>`__ protocol |
| 15 |
to allow applications to reuse its own authentication process (it means, |
| 16 |
if your are connected to Facebook, other applications can trust Facebook |
| 17 |
and let you in). |
| 18 |
|
| 19 |
You need |
| 20 |
`Net::Facebook::Oauth2 <https://metacpan.org/release/Net-Facebook-Oauth2>`__ |
| 21 |
package. |
| 22 |
|
| 23 |
You need to register a new application on Facebook to get an application |
| 24 |
ID and a secret. See https://developers.facebook.com/apps on how to do |
| 25 |
that. |
| 26 |
|
| 27 |
Configuration |
| 28 |
------------- |
| 29 |
|
| 30 |
In Manager, go in ``General Parameters`` > ``Authentication modules`` |
| 31 |
and choose Facebook for authentication module. You can also use Facebook |
| 32 |
as user database. |
| 33 |
|
| 34 |
Then, go in ``Facebook parameters``: |
| 35 |
|
| 36 |
- **Authentication level**: authentication level for this module. |
| 37 |
- **Facebook application ID**: the application ID you get |
| 38 |
- **Facebook application secret**: the corresponding secret |
| 39 |
- **User field**: Facebook field that will be used as default user |
| 40 |
identifier |
| 41 |
|
| 42 |
If you use Facebook as user database, declare values in exported |
| 43 |
variables: |
| 44 |
|
| 45 |
- use any key name you want. If you want to refuse access when a data |
| 46 |
is missing, just add a "!" before the key name |
| 47 |
- in the value field, set the field name. You can show them using |
| 48 |
`Facebook Graph API |
| 49 |
explorer <https://developers.facebook.com/tools/explorer>`__ and have |
| 50 |
a list of supported fields in the `Graph API User |
| 51 |
reference <https://developers.facebook.com/docs/graph-api/reference/user/>`__. |
| 52 |
For example: |
| 53 |
|
| 54 |
- cn => name |
| 55 |
- mail => email |
| 56 |
- sn => last_name |
| 57 |
|
| 58 |
|
| 59 |
.. attention:: |
| 60 |
|
| 61 |
Do not query user field in exported variables, as it is |
| 62 |
already registered by the authentication module in ``$_user``. |
| 63 |
|
| 64 |
|
| 65 |
.. attention:: |
| 66 |
|
| 67 |
Browser implementations of formAction directive are |
| 68 |
inconsistent (e.g. Firefox doesn't block the redirects whereas Chrome |
| 69 |
does). Administrators may have to modify formAction value with wildcard |
| 70 |
likes \*. |
| 71 |
|
| 72 |
In Manager, go in : |
| 73 |
|
| 74 |
``General Parameters`` > ``Advanced Parameters`` > ``Security`` > |
| 75 |
``Content Security Policy`` > ``Form destination`` |
| 76 |
|
| 77 |
|
| 78 |
.. tip:: |
| 79 |
|
| 80 |
You can use the same Facebook access token in your |
| 81 |
applications. It is stored in session data under the name ``$_facebookToken``\ |