WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...

    Module TokenBlacklistService

    Token Blacklist Service - Secure JWT refresh token revocation and management

    Manages revoked JWT refresh tokens to prevent reuse after logout and provides automated cleanup functionality.

    This service acts as the core security component for JWT refresh token management in the authentication system. It provides secure token revocation functionality by maintaining a persistent blacklist of revoked refresh tokens in the database. When users log out, their refresh tokens are added to this blacklist to prevent unauthorized reuse. The service integrates with the authentication flow to check token validity during refresh operations and includes automated cleanup of expired tokens to maintain optimal database performance. This service is used by the AuthController for logout operations and token refresh validation, and by the DatabaseOptimizer for periodic maintenance tasks.

    ARCHITECTURAL NOTE ON ACCESS TOKENS: This service intentionally focuses on blacklisting refresh tokens only. While blacklisting access tokens would provide immediate invalidation upon logout, it would require a database check on every single authenticated API request, introducing significant performance overhead.

    The security strategy is to keep access tokens short-lived (e.g., 15 minutes). Revoking the refresh token prevents the user from obtaining a new session, which is the most critical security measure for long-term protection. This approach represents a standard industry trade-off between absolute security and performance.

    Main service class providing token revocation and validation functionality. Adds a refresh token to the blacklist to prevent reuse. Checks if a refresh token has been revoked/blacklisted. Removes expired tokens from blacklist for maintenance.

    Exequiel Trujillo

    1.0.0

    Classes

    TokenBlacklistService