Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
django-user-sessions-ng
Advanced tools
Django User Sessions NG - a Django package to manage multiple user sessions.
django-user-sessions-ng
is a Django package which allows users to have multiple sessions and provides session management through the Django admin interface.
This project is originally inspired by (and based on) the following projects:
The changes made in this repo, however, are very minimal, and the package itself is more like an adaptation for personal use.
Install the package using your favorite package manager, for example pip:
pip install django-user-sessions-ng
Add django_user_sessions_ng
to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...,
"django_user_sessions_ng",
]
Add django_user_sessions_ng.middleware.SessionMiddleware
to your MIDDLEWARE setting like this:
MIDDLEWARE = [
...,
"django_user_sessions_ng.middleware.SessionMiddleware",
]
Set SESSION_ENGINE
to django_user_sessions_ng.backends.db
or django_user_sessions_ng.backends.cached_db
depending on your preferences and whether you need cached db in your Django settings file:
SESSION_ENGINE = "django_user_sessions_ng.backends.db"
or
SESSION_ENGINE = "django_user_sessions_ng.backends.cached_db"
Run python manage.py migrate
to create the necessary models.
(Optional) In order to enable the location information for each session, you will need to install the package called geoip2
and download the GeoLite2 database from MaxMind or using the built-in python manage.py download_geoip_db -k MAXMIND_LICENSE_KEY
command (you can get the MAXMIND_LICENSE_KEY
by registering at their website and registering a new license key) and set the GEOIP_PATH
setting in your Django settings file to the path of the database file or directory containing multiple databases.
For example:
GEOIP_PATH = "/path/to/GeoLite2"
or
GEOIP_PATH = "/path/to/GeoLite2/GeoLite2-City.mmdb"
Since this package replaces the functionality of the default Django session application (django.contrib.sessions), it is recommended to remove the django.contrib.sessions
from the INSTALLED_APPS
setting as well as django.contrib.sessions.middleware.SessionMiddleware
from the MIDDLEWARE
setting.
The package provides a management command clearsessions
(simply imports the one from the original django.contrib.sessions
package) which can be used to clear expired sessions. This command can be run using the following command:
python manage.py django_user_sessions_ng clearsessions
If for some reason the MaxMind base url for download changes, and the package doesn't get updated in time, there's an optional argument -u
or --maxmind-geoip-download-base-url
for the download_geoip_db
command which can be used to specify the base url for downloading the database files.
For example:
python manage.py download_geoip_db -k MAXMIND_LICENSE_KEY -u "https://download.maxmind.com/app/geoip_download"
cached_db
implementation.MIT
FAQs
Django User Sessions NG - a Django package to manage multiple user sessions.
We found that django-user-sessions-ng 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.