Commit Graph

8 Commits

Author SHA1 Message Date
Felipe Cardoso
453016629f Refactor and enhance token decoding error handling
Improved the `decode_token` function to clarify and extend error handling for token validation and decoding. Enhanced error messages for invalid tokens, added checks for missing claims, and ensured clear differentiation of failure scenarios. Updated imports and added a `scope` field to token response for completeness.
2025-02-28 19:05:08 +01:00
Felipe Cardoso
0bc9263d24 Refactor and enhance token decoding error handling
Improved the `decode_token` function to clarify and extend error handling for token validation and decoding. Enhanced error messages for invalid tokens, added checks for missing claims, and ensured clear differentiation of failure scenarios. Updated imports and added a `scope` field to token response for completeness.
2025-02-28 18:12:39 +01:00
Felipe Cardoso
8814dc931f Add token revocation mechanism and support for logout APIs
This commit introduces a system to revoke tokens by storing their `jti` in a new `RevokedToken` model. It includes APIs for logging out (revoking a current token) and logging out from all devices (revoking all tokens). Additionally, token validation now checks revocation status during the decode process.
2025-02-28 17:45:33 +01:00
Felipe Cardoso
af53b52c0c Refactor token creation logic and fix datetime usage
Adjusted `datetime.utcnow` to `datetime.now` for consistency and refactored token creation functions for cleaner structure. Removed duplicated `create_access_token` and `create_refresh_token` definitions by consolidating them into a single location.
2025-02-28 17:32:20 +01:00
Felipe Cardoso
3912537477 Handle additional JWT and JOSE error cases in token validation.
Expanded exception handling to cover more specific JWT and JOSE-related errors, including signature verification failures and malformed tokens. This ensures better error messaging and robustness in token validation.
2025-02-28 17:01:57 +01:00
Felipe Cardoso
548880b468 Refactor token handling and introduce token revocation logic
Updated `decode_token` for stricter validation of token claims and explicit error handling. Added utilities for token revocation and verification, improving
2025-02-28 16:57:57 +01:00
Felipe Cardoso
c3a55b26c7 Add tests for auth dependencies and security utilities
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 49s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduced unit tests for `get_current_user`, `get_current_active_user`, and security functions like token creation and decoding. Also refactored imports for consistency and cleaned up unused or misplaced code to improve maintainability.
2025-02-28 16:34:59 +01:00
Felipe Cardoso
43df9d73b0 Add foundational user authentication and registration system
Introduces schemas for user management, token handling, and password hashing. Implements routes for user registration, login, token refresh, and user info retrieval. Sets up authentication dependencies and integrates the API router with the application.
2025-02-28 16:18:03 +01:00