Merge pull request #5 from Grazulex/fix/php-requirement-rate-limiting

fix: align PHP requirement and implement rate limiting
This commit is contained in:
Jean-Marc Strauven
2025-12-30 15:35:29 +01:00
committed by GitHub
4 changed files with 13 additions and 11 deletions

View File

@@ -6,7 +6,7 @@
"keywords": ["laravel", "api", "rest", "starter-kit", "sanctum"],
"license": "MIT",
"require": {
"php": "^8.2",
"php": "^8.3",
"dedoc/scramble": "^0.12",
"grazulex/laravel-apiroute": "^1.2",
"laravel/framework": "^12.0",

4
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "26f2e475137ed47c6dc58bd554c8a91e",
"content-hash": "e6f1d7122781eed56575ee487696ba47",
"packages": [
{
"name": "brick/math",
@@ -9799,7 +9799,7 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^8.2"
"php": "^8.3"
},
"platform-dev": [],
"plugin-api-version": "2.6.0"

View File

@@ -17,13 +17,17 @@ use Illuminate\Support\Facades\Route;
// Version 1 - Current stable version
ApiRoute::version('v1', function () {
// Public routes
Route::post('register', [AuthController::class, 'register'])->name('api.v1.register');
Route::post('login', [AuthController::class, 'login'])->name('api.v1.login');
// Public routes with auth rate limiter (5/min - brute force protection)
Route::middleware('throttle:auth')->group(function () {
Route::post('register', [AuthController::class, 'register'])->name('api.v1.register');
Route::post('login', [AuthController::class, 'login'])->name('api.v1.login');
});
// Protected routes
Route::middleware('auth:sanctum')->group(function () {
// Protected routes with authenticated rate limiter (120/min)
Route::middleware(['auth:sanctum', 'throttle:authenticated'])->group(function () {
Route::post('logout', [AuthController::class, 'logout'])->name('api.v1.logout');
Route::get('me', [AuthController::class, 'me'])->name('api.v1.me');
});
})->current();
})
->current()
->rateLimit(60); // Global rate limit: 60 requests/minute for v1

View File

@@ -1,6 +1,4 @@
<?php
use Illuminate\Support\Facades\Route;
// Web routes disabled - API only application
// Scramble documentation available at /docs/api