fix: prevent sensitive field leaks in /me, add retry logic to Brent price sources
- Made `/api/auth/me` public and return explicit allowlist (name, email, two_factor_confirmed_at, tier, subscription fields) instead of spreading `$user->toArray()` which leaked is_admin, stripe_id, pm_type, pm_last_four, postcode. Returns `null` when unauthenticated rather than 401. - Moved `/auth/logout` to remain behind auth:sanctum gate. - Added 3×200ms retry with exponential backoff to EiaBrentPriceSource and FredBrentPriceSource on ConnectionException or 5xx responses. Timeout raised from 10s to 30s. - Both sources now throw typed BrentPriceFetchException on exhausted retries instead of silently returning null + logging. Updated tests to assert exception message includes HTTP status or "connection failed".
This commit is contained in:
@@ -12,6 +12,7 @@ use Illuminate\Support\Facades\Route;
|
||||
// Public endpoints (no API key required)
|
||||
Route::post('/auth/register', [AuthController::class, 'register']);
|
||||
Route::post('/auth/login', [AuthController::class, 'login']);
|
||||
Route::get('/auth/me', [AuthController::class, 'me']);
|
||||
|
||||
Route::get('/fuel-types', function () {
|
||||
return Cache::remember('api:fuel-types', now()->addDay(), fn () => collect(FuelType::cases())
|
||||
@@ -29,7 +30,6 @@ Route::middleware(['throttle:60,1', VerifyApiKey::class])->group(function (): vo
|
||||
|
||||
// Sanctum-authenticated endpoints
|
||||
Route::middleware('auth:sanctum')->group(function (): void {
|
||||
Route::get('/auth/me', [AuthController::class, 'me']);
|
||||
Route::post('/auth/logout', [AuthController::class, 'logout']);
|
||||
|
||||
// User dashboard endpoints
|
||||
|
||||
Reference in New Issue
Block a user