2017 © Pedro Peláez
 

library api-auth

Laravel package for extending Laravel Passport

image

mannysoft/api-auth

Laravel package for extending Laravel Passport

  • Thursday, June 7, 2018
  • by mannysoft
  • Repository
  • 1 Watchers
  • 0 Stars
  • 165 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 26 % Grown

The README.md

Laravel API Authentication

Laravel package for authentication in API., (*1)

Installation

Require this package with composer., (*2)

composer require mannysoft/api-auth

```shell php artisan migrate, (*3)

```shell
php artisan passport:install

```shell php artisan passport:keys, (*4)

```shell
php artisan vendor:publish --provider="Mannysoft\ApiAuth\ServiceProvider" --tag="migrations"

Open your oauth_clients table and look for password_client, (*5)

Change your .env, (*6)

APP_OAUTH_CLIENT_ID=, (*7)

APP_OAUTH_CLIENT_SECRET=, (*8)

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider., (*9)

add the Laravel\Passport\HasApiTokens trait to your App\User model. This trait will provide a few helper methods to your model which allow you to inspect the authenticated user's token and scopes:, (*10)

<?php

namespace App;

use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use HasApiTokens, Notifiable;
}

Update your config/services.php if you are using login with facebook, (*11)

'facebook' => [
    'client_id' => env('FACEBOOK_CLIENT_ID'),
    'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
    'redirect' => env('FACEBOOK_REDIRECT'),
],

Update your config/api-auth.php depending in your needs, (*12)

Finally, in your config/auth.php configuration file, you should set the driver option of the api authentication guard to passport. This will instruct your application to use Passport's TokenGuard when authenticating incoming API requests:, (*13)

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],

Reset Password Email

To get started, override the sendPasswordResetNotification method on your User model. Within this method, you may send the notification using any notification class you choose. The password reset $token is the first argument received by the method:, (*14)

/**
 * Send the password reset notification.
 *
 * @param  string  $token
 * @return void
 */
public function sendPasswordResetNotification($token)
{
    $this->notify(new \Mannysoft\ApiAuth\Notifications\ResetPasswordNotification($token, $this->email));
}

Routes available

Route Are Cool

Configuration

Config Value Default
login_facebook
login_accountkit
login_url
logout_url
forgot_password
change_password
username
reset_password_deep_link

The Versions

07/06 2018

dev-master

9999999-dev

Laravel package for extending Laravel Passport

  Sources   Download

MIT

The Requires

 

laravel api auth