Skip to main content

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

SageTeam

PyPI release Supported Python versions Supported Django versions 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 Akbarzadeh Mehran Rahmanzadeh
Sepehr Akbarazadeh Maintainer Mehran Rahmanzadeh Maintainer

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sage-session-0.1.0.tar.gz (10.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page