Skip to main content

One-shot authentication (temporary credentials) utilities for Django.

Project description

django-ticketoffice provides one-shot authentication (a.k.a. temporary credentials) utilities for Django. It lets you create and manage tickets that allow users to perform one action on the website. As an example, Django could use it for the “password reset” action, where users authenticate using a temporary token.

Example

Restrict some URL to guests with valid invitation tickets:

from django.conf.urls import patterns, url
from django_ticketoffice.decorators import invitation_required, stamp_invitation

@invitation_required(place=u'louvre', purpose=u'visit')
@stamp_invitation  # Mark invitation as used right **after** view execution.
def visit_louvre(request):
    ticket = request.cache['invitation']  # Set by `invitation_required`.
    return u'Welcome to the Louvre museum {guest}'.format(
        guest=ticket.data['first_name'])

urlpatterns = patterns('', url('^louvre$', visit_louvre, name='louvre'))

Create and deliver tickets for this resource:

from django.utils.timezone import now
from django_ticketoffice.models import Ticket

ticket = Ticket(place=u'louvre', purpose=u'visit')
ticket.set_password(u'I love Paris')  # Encrypted in database.
ticket.expiry_datetime = now() + timedelta(days=5)  # Optional.
ticket.data = {'first_name': u'Léonard'}  # Optional.
ticket.save()

credentials = {'uuid': ticket.uuid, 'password': u'I love Paris'}
visit_url = reverse('louvre') + '?' + urlencode(credentials)

django-ticketoffice focuses on authentication. It does not send invitation emails. You may check django-mail-factory about sending emails.

Project status

django-ticketoffice is, at the moment, a proof-of-concept: it delivers basic features in order to create tickets and to use them in views. It works (you can use it), but it may lack some features (ideas are welcome), and it may change (improve) quite a bit. That said, maintainers will take care of release notes and migrations.

See also vision, roadmap and alternatives to get a better overview of project status.

Resources

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-ticketoffice-0.2.zip (25.5 kB view details)

Uploaded Source

File details

Details for the file django-ticketoffice-0.2.zip.

File metadata

File hashes

Hashes for django-ticketoffice-0.2.zip
Algorithm Hash digest
SHA256 29ef64ce56000395d6f7972629d659cb9f25695bb8a4a019498b4bd13abe8de9
MD5 551ed5be6036f9e840f73df597d87deb
BLAKE2b-256 2294ffc626309ef588f68f5dc1cb17b583c20f4959b1cbd0649a6299b33171b2

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