Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Introduction

This package contains utilities that can help to protect parts of Plone or applications build on top of the Plone framework.

protect decorator

The most common way to use plone.app.protect is through the protect decorator. This decorator takes a list of checkers as parameters: each checker will check a specific security aspect of the request. For example:

from plone.app.protect import protect
from plone.app.protect import PostOnly

@protect(PostOnly)
def SensitiveMethod(self, REQUEST=None):
    # This is only allowed with HTTP POST requests.

This relies on the protected method having a parameter called REQUEST.

HTTP POST

If you only need to allow HTTP POST requests you can use the PostOnly checker:

from plone.app.protect import PostOnly
from plone.app.protect import protect

@protect(PostOnly)
def manage_doSomething(self, param, REQUEST=None):
    pass

This checker only operators on HTTP requests; other types of requests are not checked.

Form authentication

A common problem in web applications is Cross Site Request Forgery or CSRF. This is an attack method in which an attacker tricks a browser to do a HTTP form submit to another site. To do this the attacker needs to know the exact form parameters. Form authentication is a method to make it impossible for an attacker to predict those parameters by adding an extra authenticator which can be verified.

To use the form authenticator you first need to insert it into your form. This can be done using a simple TAL statement inside your form:

<span tal:replace="structure context/@@authenticator/authenticator"/>

this will produce a HTML input element with the authentication information. Next you need to add logic somewhere to verify the authenticator. This can be done using a call to the authenticator view. For example:

authenticator=getMultiAdapter((request, context), name=u"authenticator")
if not authenticator.verify():
    raise Unauthorized

You can do the same thing more conveniently using the protect decorator:

from plone.app.protect import CheckAuthenticator
from plone.app.protect import protect

@protect(CheckAuthenticator)
def manage_doSomething(self, param, REQUEST=None):
    pass

Changelog

1.0b1 - March 7, 2008

  • Refactor the code to offer a generic protect decorator for methods which takes a list of checkers as options. Add checkers for both the authenticator verification and HTTP POST-only. [wichert]

1.0a1 - January 27, 2008

  • Initial release [wichert]

Release files for plone.app.protect 1.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plone.app.protect 1.0b1
File Size Uploaded
plone.app.protect-1.0b1.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for plone.app.protect 1.0b1
File Interpreter ABI Platform
plone.app.protect-1.0b1-py2.4.egg Legacy Egg format - - Details

Total release size:30.4 kB

Release files / plone.app.protect-1.0b1.tar.gz

Download URL plone.app.protect-1.0b1.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2a9666ee821f22b8aad56d48aeb8ae722aa00fa4ed263ca18107cc888c4db5b4
BLAKE2b-256 checksum
How to use checksums
6029e5f4d720d636846ffcca5900de54deb86b07caf3df07b4a7ab3a4d31ab11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / plone.app.protect-1.0b1-py2.4.egg

Download URL plone.app.protect-1.0b1-py2.4.egg
Size 18.2 kB
Tags Egg
SHA-256 checksum
How to use checksums
89a775eb1cb9cf3986b643c08a2cbf726367d872fce1bf7598fea29b05d91290
BLAKE2b-256 checksum
How to use checksums
99be454e9d79584f64c016c027fc6d7c5e68ac336e1823d0b07627abc56866b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0b1 This release

2 release files

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