user session & privacy session for Django
Project description
Django Sage Session
What is django-sage-session package?
django-sage-session is a useful package for per user session & private session in Django Web Framework
The Latest version of django-sage-session documentation
Project Detail
- Language: Python > 3.5
- Framework: Django > 3.1
Git Rules
S.A.G.E. team Git Rules Policy is available here:
Get Started
First install the package using pip:
$ pip install django-sage-session
Then add sage_cache to INSTALLED_APPS
:
INSTALLED_APPS = [
...
'sage_session',
...
]
Usage
For using per user session you have to modify MIDDLEWARE
in setting:
Replace django Session middleware with sage_session User Session middleware
MIDDLEWARE = [
...
'django.middleware.security.SecurityMiddleware',
'sage_session.middlewares.UserSessionMiddleware', # provided middleware for per user session
# 'django.contrib.sessions.middleware.SessionMiddleware',
...
]
For activating Privacy session add it to MIDDLEWARE
:
Add after UserSessionMiddleware
MIDDLEWARE = [
...
'sage_session.middlewares.UserSessionMiddleware', # user session
'sage_session.middlewares.UserSessionPrivacyMiddleware', # privacy session
# 'django.contrib.sessions.middleware.SessionMiddleware',
...
]
Settings
PRIVACYSESSIONS_AUTHED_ONLY = False # authentication required
PRIVACYSESSIONS_PRIVACY_IP = True # validate IP
PRIVACYSESSIONS_PRIVACY_UA = True # validate user agent
PRIVACYSESSIONS_REMOTE_ADDR_KEY = 'REMOTE_ADDR' # remote addr key in request (not recommended to change)
PRIVACYSESSIONS_REDIRECT_VIEW = None # redirect view after logging out
PRIVACYSESSIONS_FAILURE_STATUS = 400 # if not PRIVACYSESSIONS_REDIRECT_VIEW set return status code
PRIVACYSESSIONS_IPV4_LENGTH = 32 # length of ipv4 (not recommended to change)
PRIVACYSESSIONS_IPV6_LENGTH = 64 # length of ipv6 (not recommended to change)
PRIVACYSESSIONS_IP_KEY = '_privacysessions_ip' # ip key in session
PRIVACYSESSIONS_UA_KEY = '_privacysessions_ua' # user agent key in session
Admin
sage_session
also has an admin panel for User Session monitoring, It will activate when you add sage_session
to INSTALLED_APPS
Team
Sepehr Akbarazadeh Maintainer | Mehran Rahmanzadeh Maintainer |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-sage-session-0.1.0.tar.gz
.
File metadata
- Download URL: django-sage-session-0.1.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.5.0.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ae314357f5c13530edfb095eceb5fb4adfd0df4333b1ba1db3ef7ae129e9b56 |
|
MD5 | fef655cff0f6ef6b5a5e1e8dffc75fd1 |
|
BLAKE2b-256 | 32bb3909c4adef38506243645ab558dfd603294ab56edf093204c925949d98a9 |