Example #1
0
def login(req):
    # password check is missing !
    cookie = PoorSession(req)
    cookie.data['hash'] = random_string()
    # cookie data are crypted with poorwsgi secret key
    cookie.header(req, req.headers_out)
    redirect(req, '/')
Example #2
0
This test use `PoorWSGI <http://poorhttp.zeropage.cz/poorwsgi.html>`
WSGI middleware. But library could be use with anyone.
"""

from poorwsgi import Application, redirect, SERVER_RETURN, state
from poorwsgi.session import PoorSession

from wsgiref.simple_server import make_server
from inspect import cleandoc

from csrf import random_string, get_token, check_token

app = Application('test')
app.debug = True
secret = random_string(length=32)


def create_referer(req, referer):
    return "%s://%s%s" % (req.scheme, req.hostname, referer)


@app.route('/login')
def login(req):
    # password check is missing !
    cookie = PoorSession(req)
    cookie.data['hash'] = random_string()
    # cookie data are crypted with poorwsgi secret key
    cookie.header(req, req.headers_out)
    redirect(req, '/')