https://github.com/netsells/passport-client-cookie
CreateFreshApiToken for client_credentials protected routes
https://github.com/netsells/passport-client-cookie
Last synced: 30 days ago
JSON representation
CreateFreshApiToken for client_credentials protected routes
- Host: GitHub
- URL: https://github.com/netsells/passport-client-cookie
- Owner: netsells
- License: mit
- Created: 2018-03-07T11:32:02.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-13T10:40:40.000Z (over 2 years ago)
- Last Synced: 2024-09-21T19:29:38.472Z (8 months ago)
- Language: PHP
- Homepage:
- Size: 29.3 KB
- Stars: 2
- Watchers: 7
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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](https://github.com/laravel/passport) and adapted for this use-case - all credit goes to that repo._
## Installation
```bash
composer require netsells/passport-client-cookie
```Add to your app.php if not using Laravel 5.5+
```php
// Other service providers
Netsells\PassportClientCookie\ServiceProvider::class,
],
```## Usage
In `Http/Kernel.php`:
Add to your `web` middleware group, probably at the bottom.
```php
\Netsells\PassportClientCookie\Middleware\CreateFreshClientCredentialsApiToken::class,
```Replace your `CheckClientCredentials` route middleware with the passport client check:
```php
'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.