Skip to content

πŸ› Enhance CSRF token error handling and simplify token location#779

Merged
yezz123 merged 3 commits intomainfrom
fix_cookies_issue
Jan 4, 2026
Merged

πŸ› Enhance CSRF token error handling and simplify token location#779
yezz123 merged 3 commits intomainfrom
fix_cookies_issue

Conversation

@yezz123
Copy link
Copy Markdown
Owner

@yezz123 yezz123 commented Jan 4, 2026

Fixes #572


Note

  • Clarified CSRF error messaging: authx/core.py now raises a detailed MissingCSRFTokenError explaining expected header (<...CSRF_HEADER_NAME>), cookie setup via set_*_cookies, and how to disable CSRF (JWT_COOKIE_CSRF_PROTECT=False).
  • Respect configured token locations for refresh tokens: AuthX._get_token_from_request in authx/main.py now uses config.JWT_TOKEN_LOCATION as-is, enabling refresh-token retrieval from headers when configured.
  • Tests updated: Added coverage for refresh tokens in headers-only configs; adjusted CSRF assertion; split _auth_required tests to validate header-based access/refresh flows.
  • Tooling tweaks: pyproject.toml sets pytest log_cli=true and removes some lint rules.

Written by Cursor Bugbot for commit 15a0c4d. This will update automatically on new commits. Configure here.

- Removed unused flake8-pyi error codes from the ignore list in `pyproject.toml`.
- Changed `log_cli` value from string to boolean in `pytest` configuration.
- Added resolution markers for Python version compatibility in `uv.lock`.
- Introduced new packages `async-asgi-testclient` and `async-timeout` with their respective versions and dependencies.
- Updated `authx` version from 1.4.1 to 1.4.3 in `uv.lock`.
- Expanded dev-dependencies and extra dependencies for improved development tooling.
- Updated `pytz` version constraint in `uv.lock` to allow for future updates.
…guration

- Improved the error message for missing CSRF tokens to provide clearer guidance on expected headers and cookie settings.
- Simplified the logic for determining token locations by directly using the configured JWT token locations.
…ss token validation

- Introduced a new test to verify that refresh tokens can be correctly retrieved from headers when configured, addressing a previous issue with token location settings.
- Enhanced existing tests to ensure proper validation of access and refresh tokens from headers, ensuring consistent behavior across token types.
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
authx Ready Ready Preview, Comment Jan 4, 2026 10:48am

@yezz123 yezz123 added the bug Something isn't working label Jan 4, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 4, 2026

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 96.65%. Comparing base (a2a0b84) to head (15a0c4d).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #779      +/-   ##
==========================================
- Coverage   96.66%   96.65%   -0.01%     
==========================================
  Files          15       15              
  Lines         779      778       -1     
  Branches       76       76              
==========================================
- Hits          753      752       -1     
  Misses         20       20              
  Partials        6        6              

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jan 4, 2026

@yezz123 yezz123 merged commit ef0e073 into main Jan 4, 2026
30 checks passed
@yezz123 yezz123 deleted the fix_cookies_issue branch January 4, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refresh_token_required is unuseful

1 participant