Skip to content

Conversation

@Iamsdt
Copy link
Collaborator

@Iamsdt Iamsdt commented Nov 29, 2025

This pull request introduces improvements to JWT authentication handling and adds comprehensive unit tests for the authentication backend. The main changes focus on correctly parsing bearer tokens, supporting different authentication methods, and ensuring robust test coverage for various authentication scenarios.

Authentication improvements:

  • Updated the authenticate method in jwt_auth.py to properly strip the "Bearer " prefix from the token before decoding, ensuring compatibility with standard HTTP Authorization headers. [1] [2]
  • Enhanced the module loader in loader.py to support binding JWT and "none" authentication methods, allowing flexible authentication configuration.

Testing enhancements:

  • Added a new test suite test_auth_backend.py with extensive unit tests for the verify_current_user function, covering scenarios such as missing authentication config, successful authentication, error logging, and handling of edge cases like null credentials and various user_id values.

- Implement comprehensive unit tests for the JwtAuth class covering various scenarios including null credentials, missing JWT settings, expired tokens, and valid tokens.
- Create tests for handling Bearer prefix in tokens and setting WWW-Authenticate headers.
- Add unit tests for the GraphConfig class to validate auth configuration scenarios, including no auth configured, JWT auth with valid and missing environment variables, and custom auth configurations.
- Ensure proper error handling and logging for invalid configurations and authentication failures.
@Iamsdt Iamsdt linked an issue Nov 29, 2025 that may be closed by this pull request
@Iamsdt Iamsdt merged commit 4e59e1a into main Nov 29, 2025
1 check passed
@Iamsdt Iamsdt deleted the 14-api-crashes-with-500-when-jwt-auth-is-enabled branch November 29, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Crashes With 500 When JWT Auth Is Enabled

2 participants