A custom implementation of JWT (JSON Web Token) authentication(login, register, logout) for Django Rest Framework, built from scratch without relying on third-party JWT libraries. This project demonstrates deep understanding of authentication mechanisms and token generation.
- Header: Algorithm & Token Type
- Payload: User Data & Claims
- Signature: Encrypted Verification
- Custom token encoding/decoding
- Signature verification
- Token expiration handling
- Refresh token rotation
- CORS protection
urlpatterns = [
path('api/user/login', UserLogin.as_view()),
path('api/register/', UserRegister.as_view()),
path('api/logout/', UserLogout.as_view()),
]# Required packages
Django>=3.2.0
djangorestframework>=3.12.0
python-dotenv>=0.19.0# Clone repository
git clone https://github.com/yamajid/authentication
# Install dependencies
pip install -r requirements.txt
# Run migrations]
python manage.py makemigrations
python manage.py migrate
# Start server
python manage.py runservercustom_jwt_auth/
├── authentication/
│ ├── views.py
│ ├── serializers.py
│ ├── tokens.py
│ └── utils.py
├── core/
│ ├── settings.py
│ └── urls.py
└── requirements.txt
-
Token Security
- Secure signature generation
- Protected secret keys
- Token expiration
-
User Protection
- Password hashing by DRF using bcrypt
- Rate limiting
- Session management
# Run tests
python manage.py runserver
- Created by: @yamajid
Built with ❤️ by @yamajid