From version 3.4 BEdita supports by default 3 external authentication services: Facebook, Twitter and Google.
In order to make this services work, we need to add some configuration parameters in the backend configuration file (bedita.cfg):
$config['extAuthParams'] = array(...);
Facebook auth service setup.
Facebook communicates with other websites through Facebook Apps. So, we need to create a Facebook App first:
- Go to https://developers.facebook.com/
- Click "Apps" in the dropdown top menu
- Select "Create a New App"
- A modal window will open
- Insert the name of the App, the namespace (optional) and a Category, then click the "Create App" button
Once the app is created, the relative page is shown. Here we can find the App ID and the App Secret keys for our params array. Finally, we need to set our domain application:
- Open "Settings" tab from the Facebook App Page
- Add a platform
- Select website from the modal window
- Fill the "Site url" field in the "Website" section
- Save changes
An example of the params array:
$config['extAuthParams'] = array( [...] 'facebook' => array( 'keys' => array( 'appId' => '[insert your appId]', 'secret' => '[insert your app secret key]' ), 'extraUserData' => array(), //additional permissions that the app requires ), [...] );
Twitter auth service setup
Also Twitter uses Apps for the external communication. Let's see how to create a twitter app:
- go to https://apps.twitter.com
- click the "Create a New App" button
- fill all requested field for app creation
- fill also the "callback url" field with your backend http address. Afterwards, the BEdita component can auto generate a custom callback url based on the login page, but Twitter needs this field however.
Once the app is created, the relative page is shown. We can find the App Key and the App Secret keys switching to "API keys" tab, but we need to add another setting:
- Switch the "Setting" tab in the Twitter App Page
- Check "Allow this application to be used to Sign in with Twitter"
- Update settings
An example of the params array:
$config['extAuthParams'] = array( [...] 'twitter' => array( 'keys' => array( 'appId' => '[insert your API key]', 'secret' => '[insert your secret key]' ) ), [...] );
Google auth service setup
Let's see how to create a google app to use for our auth integration:
- go to https://console.developers.google.com
- click the "Create project" button
- give the project name and project id
Once the app is created, the relative page is shown. Before the generation of secret keys, we need to set the permissions:
- Switch the "APIs & auth" tab in the Google App Page and select the "API" sub tab
- Look for "Google+ API" and activate it
- Now switch to "Credentials" sub tab
- Click on "Create new client id" button
- Check "web application"
- Fill "Authorized redirect URI" with your bedita url
- Click on "Create Client ID"
Now we have a Client ID and a Client secret.
An example of the params array:
$config['extAuthParams'] = array( [...] 'google' => array( 'keys' => array( 'appId' => '[your client id]', 'secret' => '[your client secret]' ), //the permission that the app required 'extraUserData' => array(), //additional permissions that the app requires ) [...] );