feat: modernize JWT auth (SimpleJWT) + fix CI + docs#209
feat: modernize JWT auth (SimpleJWT) + fix CI + docs#209kamrankhan78694 wants to merge 5 commits intoCoders-HQ:mainfrom
Conversation
- Replace drf-jwt + django-rest-auth with SimpleJWT + dj-rest-auth - Add /api/token/ and /api/token/refresh/; keep /api-token-auth/ legacy alias - Update API auth decorators and add smoke tests Tests: docker compose -f local.yml run --rm django pytest -q codershq/api/tests.py
There was a problem hiding this comment.
Pull request overview
This PR modernizes the API authentication stack by replacing the deprecated drf-jwt and django-rest-auth packages with their modern equivalents: SimpleJWT and dj-rest-auth. The changes maintain backwards compatibility through a legacy endpoint while introducing new SimpleJWT-based authentication endpoints.
- Replace deprecated JWT authentication packages with SimpleJWT and dj-rest-auth (pinned for django-allauth 0.47.0 compatibility)
- Add modern JWT endpoints (
/api/token/and/api/token/refresh/) while maintaining backwards-compatible/api-token-auth/endpoint - Update API views to use JWTAuthentication class from SimpleJWT
- Add smoke tests for token authentication and legacy endpoint compatibility
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| requirements/base.txt | Updates JWT and REST auth dependencies; also includes hiredis version upgrade (appears unrelated to JWT changes) |
| config/urls.py | Replaces old JWT imports with SimpleJWT views; adds new token endpoints and legacy compatibility view |
| config/settings/base.py | Updates installed apps to use dj-rest-auth; configures SimpleJWT with Bearer/JWT auth header support |
| codershq/api/views.py | Replaces JSONWebTokenAuthentication with JWTAuthentication in view decorators; updates route list |
| codershq/api/auth_views.py | New file implementing backwards-compatible legacy token endpoint that returns both old and new token formats |
| codershq/api/tests.py | New test file with authentication smoke tests covering token obtain, permissions, and legacy endpoint |
| README.md | Adds comprehensive JWT authentication documentation with usage examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replace drf-jwt + django-rest-auth with SimpleJWT + dj-rest-auth - Add /api/token/, /api/token/refresh/ endpoints; keep legacy /api-token-auth/ - Fix CI: bump flake8, add per-file-ignores, resolve lint violations - Update docs: docker compose v2, JWT auth section, clean mdBook build
|
can we proceed @alchatti @vatsalyagoel @Musab0 @naisofly ? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 40 out of 60 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| djangorestframework-simplejwt==5.3.1 # https://pypi.org/project/djangorestframework-simplejwt/ | ||
| dj-rest-auth[with_social]==2.2.8 # https://pypi.org/project/dj-rest-auth/ |
There was a problem hiding this comment.
The version djangorestframework-simplejwt==5.3.1 was released in September 2023. As of the current date (January 2026), this version is over 2 years old. Consider upgrading to a more recent version to benefit from bug fixes, security patches, and new features. Check the changelog at https://github.com/jazzband/djangorestframework-simplejwt/releases for any important updates.
| django-cors-headers==3.13.0 # https://pypi.org/project/django-cors-headers/ | ||
| django-rest-auth[with_social]==0.9.5 # https://pypi.org/project/django-rest-auth/ | ||
| djangorestframework-simplejwt==5.3.1 # https://pypi.org/project/djangorestframework-simplejwt/ | ||
| dj-rest-auth[with_social]==2.2.8 # https://pypi.org/project/dj-rest-auth/ |
There was a problem hiding this comment.
The version dj-rest-auth==2.2.8 was released in early 2023. Consider checking for a more recent version to ensure you have the latest bug fixes and security updates. The package is actively maintained, and newer versions may be available.
| - repo: https://github.com/PyCQA/flake8 | ||
| rev: 4.0.1 | ||
| rev: 7.1.1 | ||
| hooks: | ||
| - id: flake8 | ||
| args: ["--config=setup.cfg"] |
There was a problem hiding this comment.
The flake8 version has been upgraded from 4.0.1 to 7.1.1, which is a major version jump (3 major versions). This is a significant upgrade that may introduce new linting rules or behavior changes. Ensure that all team members are aware of this upgrade and that any new linting errors are addressed. Consider documenting this change in the PR description or migration notes.
Summary
Changes
Verification
Backwards Compatibility
How to Test