The social authentification package for Bow Framework.
This package use the [thephpleague/oauth2-client
](https://github.com/thephpleague/oauth2-client](https://github.com/thephpleague/oauth2-client) for make a wrapper.
Actualy it support the following provider:
- Gitlab
- Github
For install this package you must use composer. We recommand you to install it in globaly.
composer require bowphp/soauth
After you installation. In you .env.json
, you must define the provider acces information like this:
You can create the new facebook application in https://developers.facebook.com/.
FACEBACK_CLIENT_ID=client_id
FACEBACK_CLIENT_SECRET=client_secret
FACEBACK_REDIRECT_URI=redirect_uri
GITLAB_CLIENT_ID=client_id
GITLAB_CLIENT_SECRET=client_secret
GITLAB_REDIRECT_URI=redirect_uri
GITHUB_CLIENT_ID=client_id
GITHUB_CLIENT_SECRET=client_secret
GITHUB_REDIRECT_URI=redirect_uri
For use the package, you must import the package configuration:
return [
\Bow\Soauth\SoauthConfiguration::class,
...
];
We consider the following controller:
<?php
namespace App\Controllers;
use App\Controllers\Controller;
use Bow\Soauth\Soauth;
class SoauthController extends Controller
{
/**
* Redirect to the define provider
*
* @param string $provider
* @return mixed
*/
public function redirect($provider)
{
return Soauth::redirect($provider, $scope);
}
/**
* Handle oauth information
*
* @param string $provider
* @return mixed
*/
public function handle($provider)
{
$user = Soauth::resource($provider);
}
}
Define the route who will use for call soauth actions:
$app->get('/oauth/:provider/redirect', 'SoauthController::redirect');
$app->get('/oauth/:provider/callback', 'SoauthController::handle');
Franck DAKIA is a Full Stack developer based in Africa, Ivory Coast. Passionate about code and collaborative development, speaker, trainer and member of several developer communities and many collaborators.
Contact: [email protected] - @franck_dakia
Please, if there is a bug on the project please contact me by email or leave me a message on the slack.
Feel free to give your opinion on the quality of the documentation or suggest corrections.