django-cookieless 0.7 : Python Package Index

django-cookieless 0.7

Django cookie free sessions optional decorator

Latest Version: 0.9

Django Cookieless

Ed Crewe - December 2012

Overview

This package provides a sessions implementation and decorator class for views to allow for forms to maintain state without using cookies by posting the session id between forms, or via urls.

Django requires cookies to maintain session, and hence for authorisation.

This package is designed to cater for anonymous user session maintenance, without cookies.

WARNING : There are security issues with this, since it is not possible to use CSRF protection without session Cookies to maintain a separate token from that passed via the URL or form posts.

However there are cases when forms are used on a public site, where setting cookies is not desirable (due to privacy legislation), since technically they are not required for anonymous users to respond to forms. So if used, may necessitate requesting permission to set cookies, from the user.

Hence this package was devised to allow django to deliver multipage forms, without using cookies.

To ameliorate the security implications, a whitelist of allowed domains, can be set in the configuration.

Usage can also be restricted to a particular URL.

As another safety measure, handling of GET requests can be turned off, so that the encrypted session id is not present in any URLs.

Please NOTE: It is not advisable to use this package without some form of the above restrictions being in place.

For the purposes of using both cookie based and cookieless sessions together, there is a custom cookieless_signal(sender=request, created) and a 'no_cookies' flag when cookieless sessions are saved.

Both cater for hooking up custom code for handling these less secure sessions.

The package provides a decorator utility to turn off cookie setting for particular views (which also sets the csrf_exempt flag).

The package also handles the case of session handling for anonymous users with cookies disabled in the browser.

You can decorate views to prevent them setting cookies, whilst still retaining the use of Sessions. Usually this is easiest done in the urls.py of your core application ...

from cookieless.decorators import no_cookies

>>> urlpatterns = patterns('',
... url(r'^view_function/(\d{1,6})

, no_cookies(view_function)), ... url(r'^view_class/(\d{1,6}) , no_cookies(ViewClass.as_view())), ...)

Note that if a number of browser tabs are open on to a site with cookieless, they will each maintain a completely separate session, since without cookies the session is tied to the session posted from the pages accessed, not the client as a whole.

In cases where this is not the desired behaviour, then it can be reduced by using URL rewriting to make any links to open other windows pass session across. However of course this also means that potentially a session can be shared across browsers, too.

Installation

To install add the package via pip or other build tool, e.g. bin/pip install django-cookieless

Then replace the standard Session in the middleware settings:

>>> MIDDLEWARE_CLASSES = (
... 'django.middleware.gzip.GZipMiddleware',
... 'django.middleware.common.CommonMiddleware',
... 'django.middleware.transaction.TransactionMiddleware',
... # 'django.contrib.sessions.middleware.SessionMiddleware',
... 'cookieless.middleware.CookielessSessionMiddleware',
...)

django-cookieless 0.7 : Python Package Index的更多相关文章

  1. Ghost.py 0.1b3 : Python Package Index

    Ghost.py 0.1b3 : Python Package Index Ghost.py 0.1b3 Download Ghost.py-0.1b3.tar.gz Webkit based web ...

  2. pyrailgun 0.24 : Python Package Index

    pyrailgun 0.24 : Python Package Index pyrailgun 0.24 Download pyrailgun-0.24.zip Fast Crawler For Py ...

  3. qrcode 4.0.4 : Python Package Index

    qrcode 4.0.4 : Python Package Index qrcode 4.0.4 Download qrcode-4.0.4.tar.gz QR Code image generato ...

  4. bottle-session 0.3 : Python Package Index

    bottle-session 0.3 : Python Package Index bottle-session 0.3

  5. bottle-session 0.2 : Python Package Index

    bottle-session 0.2 : Python Package Index bottle-session 0.2 Download bottle-session-0.2.tar.gz Redi ...

  6. graphterm 0.40.1 : Python Package Index

    graphterm 0.40.1 : Python Package Index graphterm 0.40.1 Downloads ↓ A Graphical Terminal Interface ...

  7. Beaker 1.6.4 : Python Package Index

    Beaker 1.6.4 : Python Package Index Beaker 1.6.4 Download Beaker-1.6.4.tar.gz A Session and Caching ...

  8. Django 2.0.1 官方文档翻译: 高级教程:如何编写可重用的app (page 13)

    高级教程:如何编写可重用的app (page 13) 本节教程上接第七部分(Page 12).我们会把我们的 web-poll应用转换成一个独立的python包,你可以在新的项目中重用或者把它分享给其 ...

  9. Django 2.0.1 官方文档翻译: 文档目录 (Page 1)

    Django documentation contents 翻译完成后会做标记. 文档按照官方提供的内容一页一页的进行翻译,有些内容涉及到其他节的内容,会慢慢补上.所有的翻译内容按自己的理解来写,尽量 ...

随机推荐

  1. 导出Excel并下载,但无法定制样式的方法!

    拿来的,望原创见谅! public void EXCELDown(DataTable dt, string strFileName) { Response.ContentEncoding = Syst ...

  2. FastStone Capture(FSCapture) 注册码 _图形图像_软件教程_脚本之家

    FastStone Capture(FSCapture) 注册码 _图形图像_软件教程_脚本之家 FastStone Capture 注册码 序列号: name/用户名:TEAM JiOO key/注 ...

  3. CentOS6.4关闭触控板

    1. 检查是否安装xorg-x11-app; rpm -qa xorg-x11-apps 如果没有安装使用下面命令安装xorg-x11-app yum install xorg-x11-apps 2. ...

  4. 技术贴:解码时AVC1和H264的差别

    我一直疑问为什么有些视频解码时显示格式是:H264,大部分又是:AVC1 我在搜索编程资料时在微软的msdn上发现的: 原文:http://msdn.microsoft.com/en-us/libra ...

  5. 在CTime类中重载<<和>>

    程序代码: #include <iostream> using namespace std; class CTime//时间类 { private: unsigned short int ...

  6. ExtJS4.2 - 从 Hello World 到 自定义组件 -01 (为爱女伊兰奋斗)

    ExtJS4.2 - 从 Hello World 到 自定义组件 - 01 经验.概述.项目搭建.国际化.HelloWorld.布局 —— 为爱女伊兰而奋斗 ——少走弯路,简单才是王道 1. 写在前面 ...

  7. 【Maven】运行项目,报ClassNotFound错误

    我们在pom.xml中添加了那些依赖的jar后,一旦在代码中应用.当我们本地调试时,会报ClassNotFound错误,这是为什么?? 因为Tomcat不懂这些配置,你必须把Maven Depende ...

  8. 【centos6 , 6】linux 查看帮助文档:

    1. 使用   命令 -h 或 命令 --help ,  例: ls -h 2. man命令  : man  命令              例:man ls 3.info命令:           ...

  9. Java面试题集(1-50)

    下面的内容是对网上原有的面试题集及答案进行了全面修订之后的内容(原来的题目有很多重复无用的题以及错误的答案),参照了JDK最新版本,删除了重复题目以及EJB2.x等无用内容,补充最新面试题.知识点巩固 ...

  10. listview添加onItemClickListener

    MainActivity.java package com.wyl.listview04; import java.util.ArrayList; import java.util.HashMap; ...