Skip to main content
Help us improve Python packaging – donate today!

A Django app to provide access to protected resources via URL tokens.

Project Description



This is a system for allowing the creation and use of URLs that contain a token that allows a site visitor, even an anonymous visitor, access to pages that might not normally be allowed to visit.

For example, say you have a report page at /report/ that normally requires the permission ‘reporting.view_report’ to view. However, you’d like to be able to send emails to some friends to allow them to view this page without needing an account.

Viewpass is:

  • a utility to craft URLs with embedded, cryptographically-signed information about a permission
  • a Django middleware that intercepts URLs with these kind of URLs, and stores information about that permission onto the user object.


Add ‘viewpass’ to the INSTALLED_APPS:

    # ...

Add it to the middleware classes: This need to be after the Authentication Middleware (since we need a user!). A good arrangement could be:




Generating Viewpass URLs

You can generate the proper URL for them by using the method util.get_viewpass_url, like:

get_viewpass_url('/report/', 'reporting.view_report')

This URL will look like /report/?viewpass=STRING1:STRING2 and visitors can use this URL to visit the /report/ page.

The STRING1 and STRING2 are encoded versions of the timestamp/path/permission-to-grant and a signed copy of the path/permission-to-grant, respectively. This prevents any tampering by users trying to re-use a viewpass URL to view another page or to change the permission granted. (The timestamp is not used but can be used to create time-limited URLs; you can edit the signing.loads() call in viewpass.middleware.ViewPassMiddleware to add a max_age=<num_seconds> parameter).

As a convenience, you can also use the template tag to generate the proper URL. On the template that is used by /report/, you can include:

{% load viewpass_tags %}
<a href="{% viewpass_url 'reporting.view_report' %}">Get public URL</a>

This will show a link with the viewpass URL on it.


Viewpass is written and maintained by Joel Burton <>.

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-viewpass-1.1.0.tar.gz (5.2 kB) Copy SHA256 hash SHA256 Source None Dec 22, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page