Alr, so this project is basically me experimenting with Django and JWT-based authentication. It's not a super polished product (like i said it's a side project), but it helped me learn a bunch about REST tokens, user signups, and all that good stuff. Also why "N E B U L A"? its cause I like giving my projects cool name :P.
Why/Backstory?
– I wanted to try out JWT with Django. It's fun messing around with token-based auth. Also, this project has some inconsistencies and vulnerabilities (be mindful!). Another reason? Curiosity and practice!
- Login/Signup
Handles user registration and authentication routes. - JWT Support
Implemented JWT tokens viarest_framework_simplejwt
. - Basic Pages
There are some templates for login, signup, password reset, etc.
- manage.py: The main Django script for migrations, running the dev server, etc.
- django_auth/settings.py: Contains Django config, including JWT settings (token lifetime stuff).
- authentication/views.py: All the main auth logic: sign in, sign out, user activation, and password resets.
- authentication/urls.py: Just the route definitions.
- templates/: Contains HTML templates for login, signup, activation page, etc.
- static/js & static/scss: Some front-end styling and scripts (like jQuery, SCSS files).
-
Incoming Request
The client's browser sends an HTTP request to our Django app. -
URL Mapping
Django looks aturls.py
(both the rooturls.py
and included appurls.py
) to see which view function (or class-based view) should handle the request. -
View Logic
The selected view does the heavy lifting—grabbing data from the database, handling forms, or doing any other logic you need. -
Response
The view then returns an HTTP response (HTML, JSON, etc.) back to the user’s browser, completing the cycle.
And following is a nice little diagram to help visualize and understand more clearly...
- Clone the repo (like i said, not 100% done, so watch out):
git clone https://github.com/yourusername/django-jwt-auth.git
cd django-jwt-auth
- Set up a virtual env (just recommended):
python -m venv venv
venv\Scripts\activate
- Install requirements:
pip install -r requirements.txt
- Run server:
python manage.py runserver
- Open a browser at http://127.0.0.1:8000/auth/login to check out the app.
– Maybe thoroughly fix any vulnerabilities
– Tweak JWT config further
– Try out additional endpoints, user profile stuff, or role-based auth
– Possibly add more tests, etc.
Kappaaa, that should be it. I might/might not expand this code base later on. For now, enjoy!