Skip to main content

Rest based sessions backend for Django.

Prerequisites

This backend relies on rest-sessions for storing and managing sessions. Npm rest-sessions needs to be running and accessible at SESSION_URL.

Requirements

This package relies on the requests package. Make sure it is installed in your Django project:

pip install requests

Install

Install with pip:

pip install django-rest-sessions

Configure

After installing django-rest-sessions you must add a few settings to your settings.py

  • Add rest_sessions as your session engine:

    SESSION_ENGINE = 'rest_sessions'
  • Add django.contrib.sessions.middleware.SessionMiddleware to MIDDLEWARE_CLASSES

  • Add the name of the session cookie for Django’s session middleware:

    SESSION_COOKIE_NAME = 'session-cookie'
  • Add the path where npm rest-sessions is running:

    SESSION_URL = 'example.com/path/to/rest-sessions'
  • Add the app that is used in npm rest-sessions:

    SESSION_APP = 'mywebapp'

Usage

This session backend is mostly intended to be used in a microservice architecture and thus does not handle creating sessions since npm rest-sessions requires a user key so it would only be possible to create a session within the microservice that takes care of the users for your application. Because this is intended to add sessions to requests to all microservices written in Django it is more applicable to create sessions once a user logs in or requests a web page and use this for services handling RESTful requests that said web page makes.

Testing

To run tests the following packages are needed:

  • django

  • requests

  • requests_mock

Install them with:

pip install -r requirements.txt

Run the tests with:

python setup.py test or python setup.py xml_test which generates an xml report

Release files for django-rest-sessions 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-rest-sessions 0.2.2
File Size Uploaded
django-rest-sessions-0.2.2.tar.gz 4.2 kB Details

Release files / django-rest-sessions-0.2.2.tar.gz

Download URL django-rest-sessions-0.2.2.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fe7f2debe5bb72cc764b2820eb6b5a355a0c1c9aa21ca5885ff002615827f350
BLAKE2b-256 checksum
How to use checksums
6ecd564ba82f7df099b79a58630f47bb5452a7e27e92b22780a7a6121e9e5e0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.2 This release

1 release file

0.2.0

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page