Skip to content

Conversation

@revant
Copy link
Contributor

@revant revant commented Nov 8, 2025

No description provided.

…ility

This commit introduces significant improvements to the authentication module (`auth.py`) and its testing infrastructure.

Key changes include:
- **Enhanced JWT Verification**: Implemented proper caching for validated JWT payloads, ensuring performance for repeated token usage. Corrected `jwt.decode` input handling and added support for configurable `audience_claim_key` in `validate_signature`.
- **Refined Authentication Flows**: Streamlined user data processing in both `validate_bearer_with_introspection` and `validate_bearer_with_jwt_verification`, especially when `fetch_user_info` is enabled.
- **Improved Testability**: The monolithic `tests/test_auth.py` has been split into granular, focused test files (`test_auth_helpers.py`, `test_auth_introspection.py`, `test_jwt_existing_user.py`, `test_jwt_invalid.py`, `test_jwt_new_user.py`, `test_jwt_userinfo.py`).
- **Robust Mocking**: Introduced `tests/conftest.py` with `MockDoc` and an `autouse` `mock_frappe` fixture to provide consistent and isolated testing environments.
- **DocType Updates**: Added `audience_claim_key` to the `CFE Identity Provider` DocType to support flexible audience validation.

These changes address previous logical flaws, enhance the reliability and testability of the authentication system, and lay the groundwork for future feature development.
@revant revant merged commit 5e94812 into main Nov 8, 2025
2 checks passed
@revant revant deleted the cleanup branch November 8, 2025 03:15
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.

2 participants