Skip to main content

Django WordPress Auth

Introduction

Allows for access in Django to a WordPress installation for checking for things like login status and roles / capabilities.

Requirements

Python Dependencies:

WordPress Dependencies:

Installation

Add your WordPress’s auth keys and salts (found in wp-config.php) to your settings.py.

WORDPRESS_LOGGED_IN_KEY = "rs&^D%jPdu=vk|VVDsdfsdgsdgsdg9sd87f98s7h[Xm$3gT/@1xdasd"
WORDPRESS_LOGGED_IN_SALT = "3]x^n{d8=su23902iu09jdc09asjd09asjd09jasdV-Lv-OydAQ%?~"

Add your WordPress database to DATABASES in settings.py.

DATABASES = {
    'default': {
        ... # default django DB
    },
    'wordpress': {  # must be named 'wordpress'
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'wordpress',
        'USER': '...',
        'PASSWORD': '...',
        'HOST': '...',
        'PORT': 3306,
    }
}

Add the middleware to MIDDLEWARE_CLASSES in settings.py. Make sure it’s placed somewhere after the session middleware.

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    # ...
    'wordpress_auth.middleware.WordPressAuthMiddleware',
)

Finally, add wordpress_auth to INSTALLED_APPS.

INSTALLED_APPS = (
    # ...
    'wordpress_auth',
)

Usage

To restrict a view to a certain role, simply wrap the view in the wordpress_requires_role decorator.

from wordpress_auth.decorators import wordpress_requires_role

@wordpress_requires_role('my_role')
def my_view():
    pass

You can restrict a view to a capability as well.

from wordpress_auth.decorators import wordpress_requires_capability

@wordpress_requires_capability('my_capability')
def my_view():
    pass

Finally, the middleware provides access to the WordPress user via request.wordpress_user.

See models.py for full reference. Some of the redundant naming conventions in the WordPress database have been made simpler as well.

Metadata

Release files for django-wordpress-auth 0.1.31

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-wordpress-auth 0.1.31
File Size Uploaded Provenance Actions
django-wordpress-auth-0.1.31.tar.gz 4.7 kB Without provenance Details for django-wordpress-auth-0.1.31.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-wordpress-auth 0.1.31
File Interpreter ABI Platform Actions
django_wordpress_auth-0.1.31-py2.py3-none-any.whl Python 2, Python 3 none any Details for django_wordpress_auth-0.1.31-py2.py3-none-any.whl

Total release size: 12.6 kB

Release files / django-wordpress-auth-0.1.31.tar.gz

Download URL django-wordpress-auth-0.1.31.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c3db71ccb2c7191387f12ca75ebb7e55f504f31df0fd413d7ce2b65d4d6b20fa
BLAKE2b-256 checksum
How to use checksums
02be59d68de15c6dab2f13b57118cd068a02ffad65bc80c016d5471303091b0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_wordpress_auth-0.1.31-py2.py3-none-any.whl

Download URL django_wordpress_auth-0.1.31-py2.py3-none-any.whl
Size 7.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e8c73cabf3e993d5597f96d799cd9a39e32ebc6ffca3c6bc0949b166b12b969c
BLAKE2b-256 checksum
How to use checksums
3fcf8f7677c8c4babef17454fcfa746a3aa6c00a55a0d7d2988b660ae3299a7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-wordpress-auth 0.1.31

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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