Skip to content

CreateFreshApiToken for client_credentials protected routes

License

Notifications You must be signed in to change notification settings

neondigital/passport-client-cookie

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Passport Client Cookie

This package provides the same cookie based auth that the CreateFreshApiToken middleware does, but for client_credentials. This is useful when you protect non-user routes, but still want to consume them on the frontend without introducing a proxy.

Most of the code contained in this package is taken from Laravel Passport and adapted for this use-case - all credit goes to that repo.

Installation

composer require netsells/passport-client-cookie

Add to your app.php if not using Laravel 5.5+

    // Other service providers
    Netsells\PassportClientCookie\ServiceProvider::class,
],

Usage

In Http/Kernel.php:

Add to your web middleware group, probably at the bottom.

\Netsells\PassportClientCookie\Middleware\CreateFreshClientCredentialsApiToken::class,

Replace your CheckClientCredentials route middleware with the passport client check:

'client' => \Netsells\PassportClientCookie\Middleware\CheckClientCredentials::class,

Testing

You can disable the checking middleware by pulling the WithoutClientCredentialsMiddleware trait in and calling $this->withoutClientCredentialsMiddleware() at the top of your test.

About

CreateFreshApiToken for client_credentials protected routes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%