
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
tc-django-quick-auth
Advanced tools
A reusable Django package for quick login and signup endpoints with optional JWT authentication
A reusable Django package that provides quick and easy authentication endpoints for login and signup functionality with optional JWT authentication support. Simplify your Django project's authentication system without writing boilerplate code.
pip install tc-django-quick-auth
Important Note: While the package is installed as
tc-django-quick-auth
, you'll reference it in your Python code and Django settings asdjango_quick_auth
. This follows Python package conventions where PyPI package names use hyphens, but Python module names use underscores.
Add django_quick_auth
to your INSTALLED_APPS
in your Django project's settings:
INSTALLED_APPS = [
# ...
"rest_framework",
"rest_framework_simplejwt",
'django_quick_auth',
]
If you want to use the custom QuickAuthUser
model provided by this package, add this to your settings:
AUTH_USER_MODEL = 'django_quick_auth.QuickAuthUser'
Note: If you're adding this to an existing project that already has migrations with the default Django User model, you'll need to create a migration strategy or start with a fresh database.
Include the authentication URLs in your project's urls.py
:
from django.urls import path, include
urlpatterns = [
# ...
path('api/auth/', include('django_quick_auth.urls')),
# ...
]
If you want to use JWT authentication, configure the JWT settings in your project settings:
# JWT Settings
QUICK_AUTH = {
'USE_JWT': True,
'JWT_SECRET_KEY': 'your-secret-key',
'JWT_ALGORITHM': 'HS256',
'JWT_EXPIRATION_DELTA': 24 * 60 * 60, # Token expiry time in seconds (24 hours)
'JWT_REFRESH_EXPIRATION_DELTA': 7 * 24 * 60 * 60, # Refresh token expiry time in seconds (7 days)
}
After configuring your settings, run migrations to create the necessary database tables:
python manage.py makemigrations
python manage.py migrate
Once configured, the package provides the following endpoints:
POST /api/auth/signup/ - Register a new user
{
"username": "newuser",
"email": "user@example.com",
"password": "securepassword"
}
POST /api/auth/login/ - Login with existing credentials
{
"username": "existinguser",
"password": "securepassword"
}
If JWT is enabled, successful login/signup will return:
{
"token": "your.jwt.token",
"refresh_token": "your.refresh.token",
"user": {
"id": 1,
"username": "username",
"email": "user@example.com"
}
}
You can extend the QuickAuthUser
model by creating your own model that inherits from it:
from django_quick_auth.models import QuickAuthUser
from django.db import models
class MyCustomUser(QuickAuthUser):
phone_number = models.CharField(max_length=15, blank=True)
date_of_birth = models.DateField(null=True, blank=True)
# Don't forget to update AUTH_USER_MODEL in settings to point to your custom model
You can override the default serializers by specifying them in your settings:
QUICK_AUTH = {
# Other settings...
'USER_SERIALIZER': 'myapp.serializers.MyCustomUserSerializer',
'LOGIN_SERIALIZER': 'myapp.serializers.MyCustomLoginSerializer',
'SIGNUP_SERIALIZER': 'myapp.serializers.MyCustomSignupSerializer',
}
To run the tests for this package:
pip install -e .
pip install pytest pytest-django
pytest
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
)git commit -am 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A reusable Django package for quick login and signup endpoints with optional JWT authentication
We found that tc-django-quick-auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.