Skip to main content

Utilities for Django/Python apps

Project description

Overview

DBCA Django utility classes and functions.

SSO Login Middleware

This will automatically login and create users using headers from an upstream proxy (REMOTE_USER and some others). The logout view will redirect to a separate logout page which clears the SSO session.

Usage

Add dbca_utils.middleware.SSOLoginMiddleware to settings.MIDDLEWARE (after both of django.contrib.sessions.middleware.SessionMiddleware and django.contrib.auth.middleware.AuthenticationMiddleware. Ensure that AUTHENTICATION_BACKENDS contains django.contrib.auth.backends.ModelBackend, as this middleware depends on it for retrieving the logged in user for a session. Note that the middleware will still work without it, but will reauthenticate the session on every request, and request.user.is_authenticated won't work properly/will be false.

Example:

MIDDLEWARE = [
    ...,
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'dbca_utils.middleware.SSOLoginMiddleware'
    ...,
]

Audit model mixin

AuditMixin is an extension of Django.db.model.Model that adds a number of additional fields:

  • creator - FK to AUTH_USER_MODEL, used to record the object creator
  • modifier - FK to AUTH_USER_MODEL, used to record who the object was last modified by
  • created - a timestamp that is set on initial object save
  • modified - an auto-updating timestamp (on each object save)

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

dbca-utils-2.0.2.tar.gz (9.9 kB view details)

Uploaded Source

File details

Details for the file dbca-utils-2.0.2.tar.gz.

File metadata

  • Download URL: dbca-utils-2.0.2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.17

File hashes

Hashes for dbca-utils-2.0.2.tar.gz
Algorithm Hash digest
SHA256 603692a1f7ea66d35a98edce1b6ab688e0a3c91a1b028d164a9373b5ca79eaaf
MD5 944bb94cd90b9e5835e40ba71d9ddaec
BLAKE2b-256 3bdaa7f1f44cbfd31e41bbe58e1d8f4e244ddd377c01a9651694271fd9b4e22b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page