django-cookieless 0.7 : Python Package Index
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的更多相关文章
- 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 ...
- pyrailgun 0.24 : Python Package Index
pyrailgun 0.24 : Python Package Index pyrailgun 0.24 Download pyrailgun-0.24.zip Fast Crawler For Py ...
- 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 ...
- bottle-session 0.3 : Python Package Index
bottle-session 0.3 : Python Package Index bottle-session 0.3
- 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 ...
- graphterm 0.40.1 : Python Package Index
graphterm 0.40.1 : Python Package Index graphterm 0.40.1 Downloads ↓ A Graphical Terminal Interface ...
- 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 ...
- Django 2.0.1 官方文档翻译: 高级教程:如何编写可重用的app (page 13)
高级教程:如何编写可重用的app (page 13) 本节教程上接第七部分(Page 12).我们会把我们的 web-poll应用转换成一个独立的python包,你可以在新的项目中重用或者把它分享给其 ...
- Django 2.0.1 官方文档翻译: 文档目录 (Page 1)
Django documentation contents 翻译完成后会做标记. 文档按照官方提供的内容一页一页的进行翻译,有些内容涉及到其他节的内容,会慢慢补上.所有的翻译内容按自己的理解来写,尽量 ...
随机推荐
- js中的一元运算符
一元运算符只有一个参数,即要操作的对象或值.它们是 ECMAScript 中最简单的运算符. delete delete 运算符删除对以前定义的对象属性或方法的引用.例如: var o = new O ...
- hibernate 单元测试 5.2
单元测试 测试 dao service action package com.kaishengit.test; import org.hibernate.Session; import com.ka ...
- Linux学习:netstat命令
Netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态等.对于开发来说,很多时候用于查看端口占用情况. 执行netstat命令,其输出结果可以分成两部分: 1)一是“Active ...
- 谷歌浏览器javascript调试教程
扫扫关注"茶爸爸"微信公众号 坚持最初的执着,从不曾有半点懈怠,为优秀而努力,为证明自己而活. 回复:"茶爸爸" 看看有什么!! 怎样打开Chrom ...
- [移动网关]2G环境下资源下载有一定概率失败,客户端日志显示收到403错误
2G环境下资源下载有一定概率失败,客户端日志显示收到403错误 问题现象: 测试同学在使用联通号码在移动网络环境下,访问连接得到的response_code出现是403,导致资源读取失败表情显示异常. ...
- wiki oi 3115高精度练习之减法
题目描述 Description 给出两个正整数A和B,计算A-B的值.保证A和B的位数不超过500位. 输入描述 Input Description 读入两个用空格隔开的正整数 输出描述 Outpu ...
- Group DataList
一,效果图. 二,源代码. <!DOCTYPE html><html><head> <meta charset="UTF-8"> & ...
- PHP学习笔记8-文件操作
在data文件中写入数据: <?php /** * Created by PhpStorm. * User: Administrator * Date: 2015/6/29 * Time: 17 ...
- iOS 获取字符串中的单个字符
要取到单个字符,就要知道字符串的编码方式,这样才能够定位每个字符在内存中的位置.但是,iOS的字符串编码是不固定的,因此,需要设置一个统一的编码格式,将所有其他格式的字符串都转化为统一的格式,然后就可 ...
- 【.Net基础拾遗】品味OO继承
0X1 引言 提起面向对象,每个人都有不同的见解.但提的最多的无非就是:对象.封装.继承.多态.差不多就是这些元素构成了面向对象设计开发的基本逻辑.面向对象编程,“对象”指的是什么?这里的" ...