Skip to main content

django-verification

Generalized app for two-step verification.

Supports Python 3.9-3.13; Django 3.2, 4.2, 5.2.

Installation

  1. Install the library, for instance with pip:

    pip install django-verification
  2. Add the library to your INSTALLED_APPS of an exiting project:

    INSTALLED_APPS += ['verification']
  3. Add the tables to the existing project:

    python manage.py migrate verification

Upgrade

To 0.4.1 (needs Django 1.7+):

python manage.py migrate --fake verification 0001_initial

Demo

Copy the entire django-verification directory somewhere, set up and enter a virtualenv, then provided you are on some Un*x:

make demo

This’ll automatically make a user “admin” with the password “demo”.

The demo should now be running on http://127.0.0.1/

Running make demo again will erase the database from the previous run.

Tests

To run the tests, first install the testing-requirements:

pip install -r requirements/test.txt

then run the tests with:

make test APP=verification

Usage

Create a KeyGroup. KeyGroups hold the config for your Keys, so you might want to make fixtures of them.

from verification.models import KeyGroup

keygroup = KeyGroup(
    name='activate_account', # Unique
    generator='sha1',        # See verification.generators
)

Create a Key on some event, for instance when a user clicks a button:

from verification.models import Key

Key.generate(group=keygroup)

Set Key.send_func to some callable:

from django.core.mail import send_mail

# In this minimal example, the contents of the email is created earlier
def email_key(recipient, content):
    subject = "Activate account on FooBlog"
    recipient = ''.join(recipient.strip().split())
    # Use any kind of messaging-system here
    send_mail(subject, content, 'noreply@example.com', [recipient])

key.send_func = email_key

Choose the claim-view, make the content of the email, send it with key.send_key():

from django.core.urlresolvers import reverse

activate_url = reverse('verification-claim-post-url',
        kwargs={'key': key, 'group': key.group})
content = "Click on %s to activate your account on FooBlog!" % activate_url
recipient = 'john.oe@example.com'

key.send_key(recipient, content)

Hook the key_claimed-signal in order to do something after the key is claimed:

from django.dispatch import receiver

from verification.signals import key_claimed

@receiver(key_claimed)
def user_created_key_claimed(sender, **kwargs):
    claimant = kwargs['claimant']
    claimant.is_active = True
    claimant.save()
Version:

1.4.0

Metadata

Release files for django-verification 1.4.0

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-verification 1.4.0
File Size Uploaded Provenance
django_verification-1.4.0.tar.gz 10.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-verification 1.4.0
File Interpreter ABI Platform
django_verification-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / django_verification-1.4.0.tar.gz

Download URL django_verification-1.4.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
087432185b63353e5b946f2791f9c900a4fb6288e22887c1ed61c0cb611a7a17
BLAKE2b-256 checksum
How to use checksums
b079af5e63709068dd3b192738352c4e6f2ce472b3ff0b9b033969788b946383
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / django_verification-1.4.0-py3-none-any.whl

Download URL django_verification-1.4.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c233ee33757d117acf2f12ce29a1dfc5fd5a714107f236b62863da17a3619e09
BLAKE2b-256 checksum
How to use checksums
0bd45feaf639f80002553a6f58f3a5c4a55cc032c6e5b0cb3408f86d25a9a53e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for django-verification 1.4.0

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.

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