Skip to main content

A signed Django form

Project description

A small library that provides a form class that signs a configurable set of hidden fields using django.core.signing.

The most common use case for such a form is when the view that handles the post differs from the view that sets up the form, but you need to pass some information from one view to the other, without evil hackers tampering with your precious data.

Usage

Subclass SignedForm, and define which fields should be signed:

from signedforms.forms import SignedForm

class MyForm(SignedForm):
    signed_fields = ['redirect_url',]

    redirect_url = forms.CharField(required=False, widget=forms.HiddenInput)

In the form that sets up the view, provide the data to be signed in the initial dictionary:

my_form = MyForm(initial={'redirect_url': self.request.path_info})

and in the view that handles the posted form:

def form_valid(self, form):
    # do some work
    return HttpResponseRedirect(form.cleaned_data['redirect_url'])

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-signedforms-0.1.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file django-signedforms-0.1.tar.gz.

File metadata

File hashes

Hashes for django-signedforms-0.1.tar.gz
Algorithm Hash digest
SHA256 68f8d36058d9031c1c2f9ae2fe305b7d3f65fcc01cf807701bd2f17a3ae8188f
MD5 2d888a795464260b3844be4ae2d274b3
BLAKE2b-256 8e8b779486722f1872b9947931c23066aaa5275dbcdf9562a85d213bede6a665

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