vdhoangson / laravel-api-auth
There is no license information available for the latest version (v1.0) of this package.
Laravel Api Authentication
Package info
github.com/vdhoangson/laravel-api-auth
Type:module
pkg:composer/vdhoangson/laravel-api-auth
Fund package maintenance!
v1.0
2025-06-05 07:25 UTC
Requires
- php: ^8.2
README
A simple Laravel package for API authentication using custom client credentials via headers.
Installation
- Install the package
composer require vdhoangson/laravel-api-auth
- Register the Service Provider (if not auto-discovered)
Add to bootstrap/providers.php:
(This package autoload provider)
Vdhoangson\LaravelApiAuth\LaravelApiAuthServiceProvider::class,
- Publish config and run migrations
php artisan vendor:publish --tag=laravel-api-auth-config php artisan migrate
- Add data to the
api_clientstable
Create a record with the fields: name, client, client_secret.
- Use the middleware in your routes
Route::middleware('client-auth')->get('/test', function () { return response()->json(['message' => 'Authenticated!']); });
- Send a test request
Send a request with the following headers:
X-ClientX-Client-Secret
Example:
curl -H "X-Client: your_client" -H "X-Client-Secret: your_secret" http://your-app.local/api/test
Funding
If you find this package helpful, you can support the author via GitHub Sponsors:
github.com/sponsors/vdhoangson
License
MIT