Skip to main content
The security core of this API rests on a stateless authentication model using JSON Web Tokens (JWT) and a strict Role-Based Access Control (RBAC) architecture.

🔑 Stateless Authentication (JWT)

The authentication flow is centralized in the AuthController, designed to be lightweight, secure, and fully adapted to language switching.
/api/v1/auth/login
Validates credentials and issues a signed JWT token if the user is active and correctly authenticated.

🛡️ Validation and Security Flow

  1. Credential Verification: Validates email and encrypted password using Laravel’s Hash facade.
  2. Logical Deletion Protection: If the user exists but has been deactivated (Soft Delete), the system blocks access with a 403 Forbidden code, preventing the token issuance.
  3. Brute Force Prevention: The route is protected by a perimeter middleware (throttle:4,1) that blocks the IP for one minute after 4 failed attempts.

🛂 Role-Based Access Control (RBAC)

Once the token is issued, authorization of protected routes is delegated to the custom CheckRole middleware. This component intercepts requests, extracts the authenticated user’s profile, and dynamically verifies their privileges.

🚦 Interception Logic

The middleware leverages the Many-to-Many relationship between Eloquent’s User and Role. It uses PHP’s native spread operator (...$roles) to receive a variable amount of allowed roles directly from the route definition.

🛤️ Clean Implementation in the Router

This architecture allows protecting entire groups of endpoints with a declarative and highly readable syntax in the routes file.