namewithin/auth-client

There is no license information available for the latest version (2.0) of this package.

Advanced auth for Laravel Passport

2.0 2019-11-20 15:23 UTC

This package is auto-updated.

Last update: 2022-09-22 09:33:40 UTC


README

Requirements

  • laravel/framework: ~6.0
  • laravel/passport: ^7.0

Installation

The library can be installed using Composer.

Add vcs repository url to the composer.json:

"repositories": [
    {
        "type": "vcs",
        "url": "git@github.com:namewithin/auth-client.git"
    }
]

Install

composer require namewithin/auth-client

Usage

You can define guard with the client provider in the config/auth.php

'guards' => [
    'client-guard' => [
        'driver-guard' => 'client-driver',
        'provider'     => 'client',
    ],
],

Now you can protect your routes, only need to add the auth guard to auth middleware:

Route::get('profile', function () {
    // Only authenticated clients may enter...
})->middleware('auth:client-guard');

Route::group([
    'middleware' => ['auth:api,client-guard'], // Only authenticated users and clients may enter...
], function () {
    Route::get('ticket/{id}/history', 'HistoryController@ticket');
});