italofantone / api-token-validator
A simple package to validate API tokens with Laravel. Middleware to protect routes using valid tokens.
v1.0.1
2024-12-18 13:44 UTC
Requires
- php: ^8.1
- illuminate/database: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^9.2
- phpunit/phpunit: ^11.3
README
A simple package to validate API tokens with Laravel. Middleware to protect routes using valid tokens.
⚠️ This code was used for educational purposes [...]
Installation
You can install the package via composer. Run the following command:
composer require italofantone/api-token-validator
Usage
File .env: API_TOKEN_VALIDATOR=secret
.
<?php
use Illuminate\Support\Facades\Route;
use Italofantone\ApiTokenValidator\Http\Middleware\EnsureApiTokenIsValid;
Route::get('protected-route', function () {
return response()->json([
'message' => 'You are authorized to access this route!',
]);
})
->middleware(EnsureApiTokenIsValid::class)
->name('protected-route');
Contact
- Email: i@rimorsoft.com
- Twitter: @italofantone
- LinkedIn: italofantone
Donations
If you find this project useful and would like to support its development, you can make a donation via PayPal:
- PayPal: Donate via PayPal
Thank you for your support!