Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🔐 Custom JWT Authentication System

Overview

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.

🌟 Key Features

🛠 Core Components

Token Structure

  • Header: Algorithm & Token Type
  • Payload: User Data & Claims
  • Signature: Encrypted Verification

💻 Technical Implementation

Security Features

  • Custom token encoding/decoding
  • Signature verification
  • Token expiration handling
  • Refresh token rotation
  • CORS protection

API Endpoints

urlpatterns = [
    path('api/user/login', UserLogin.as_view()),
    path('api/register/', UserRegister.as_view()),
    path('api/logout/', UserLogout.as_view()),
]

🚀 Getting Started

Prerequisites

# Required packages
Django>=3.2.0
djangorestframework>=3.12.0
python-dotenv>=0.19.0

Installation

# 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 runserver

📝 Project Structure

custom_jwt_auth/
├── authentication/
│   ├── views.py
│   ├── serializers.py
│   ├── tokens.py
│   └── utils.py
├── core/
│   ├── settings.py
│   └── urls.py
└── requirements.txt

🛡️ Security Considerations

  1. Token Security

    • Secure signature generation
    • Protected secret keys
    • Token expiration
  2. User Protection

    • Password hashing by DRF using bcrypt
    • Rate limiting
    • Session management

🔍 Testing

# Run tests
python manage.py runserver

👤 Author

  • Created by: @yamajid

Built with ❤️ by @yamajid

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages