Backend for an api to authenticate users, including both local and social authentication.
It uses Laravel Passport for API authentication and tokens, and Laravel Socialite for social authentication. These packages are automatically included.
In the future, this package will work in conjunction with a front-end component pack.
Via Composer
$ composer require jijoel/laravel-auth-api
To scaffold the authentication controllers:
$ php artisan make:api-auth
To automatically generate routes, include this in routes/api.php
:
ApiAuth::routes();
ApiAuth::socialRoutes(); // oauth routes
ApiAuth::routes(['social']); // include oauth routes
Add a relationship to linked social accounts to your user model:
public function linkedSocialAccounts()
{
return $this->hasMany('Jijoel\AuthApi\LinkedSocialAccount');
}
The ApiAuth::routes()
method, above, will create these endpoints:
Methods | Route | Route Name |
---|---|---|
POST | api/login | login |
POST | api/logout | logout |
GET | HEAD | api/oauth/{driver} |
GET | HEAD | api/oauth/{driver}/callback |
POST | api/password/email | password.email |
POST | api/password/reset | password.reset |
POST | api/register | register |
It also sets up an @config blade compiler directive, so you can load application-specific configuration into your javascript. By default, it will include this configuration:
'appName' => config('app.name'),
'locale' => $locale = app()->getLocale(),
'locales' => config('app.locales'),
Please see the changelog for more information on what has changed recently.
$ phpunit
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email instead of using the issue tracker.
license. Please see the license file for more information.