JWT Authentication

  1. Rate Limiting
  2. JWT Authentication
  3. Idempotency
  4. API Keys
  5. API Versioning
  6. Pagination
  7. Consistent Error Format
Client
Server

Before

class OrderController
{
    public function index(Request $request): JsonResponse
    {
        $userId = $request->header('X-User-Id');

        // nothing stops a caller from sending any value here
        return response()->json(
            Order::where('user_id', $userId)->get()
        );
    }
}

After

class OrderController
{
    public function index(Request $request): JsonResponse
    {
        $token = JwtToken::verify($request->bearerToken());

        // signature checked against a shared secret, no DB lookup
        return response()->json(
            Order::where('user_id', $token->claim('sub'))->get()
        );
    }
}
{CC}