Merge branch 'master' of github.com:aio-libs/aiohttp_security

This commit is contained in:
Andrew Svetlov 2015-11-02 22:29:11 +02:00
commit e9065305ad
3 changed files with 18 additions and 26 deletions

View File

@ -1,15 +1,12 @@
language: python language: python
python: python:
- 3.3
- 3.4 - 3.4
- 3.5
install: install:
- pip install --upgrade setuptools - pip install --upgrade pip
- pip install pyflakes - pip install -r requirements-dev.txt
- pip install pep8 - pip install coveralls
- pip install coveralls --use-mirrors
- pip install aiohttp
- python setup.py develop
script: script:
- pyflakes aiohttp_security tests - pyflakes aiohttp_security tests

View File

@ -11,8 +11,10 @@ AUTZ_KEY = 'aiohttp_security_autz_policy'
def remember(request, response, identity, **kwargs): def remember(request, response, identity, **kwargs):
"""Remember identity into response. """Remember identity into response.
The action is performed by indentity_policy.remember() The action is performed by identity_policy.remember()
Usually the idenity is stored in user cookies homehow.
Usually the idenity is stored in user cookies homehow but may be
pushed into custom header also.
""" """
assert isinstance(identity, str), identity assert isinstance(identity, str), identity
identity_policy = request.app.get(IDENTITY_KEY) identity_policy = request.app.get(IDENTITY_KEY)
@ -28,8 +30,11 @@ def remember(request, response, identity, **kwargs):
@asyncio.coroutine @asyncio.coroutine
def forget(request, response): def forget(request, response):
"""Forget previously remembered identity.""" """Forget previously remembered identity.
Usually it clears cookie or server-side storage to forget user
session.
"""
identity_policy = request.app.get(IDENTITY_KEY) identity_policy = request.app.get(IDENTITY_KEY)
if identity_policy is None: if identity_policy is None:
text = ("Security subsystem is not initialized, " text = ("Security subsystem is not initialized, "

View File

@ -2,28 +2,18 @@ import codecs
from setuptools import setup, find_packages from setuptools import setup, find_packages
import os import os
import re import re
import subprocess
import sys import sys
from setuptools.command.test import test as TestCommand from setuptools.command.test import test as TestCommand
class PyTest(TestCommand): class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] user_options = []
def initialize_options(self): def run(self):
TestCommand.initialize_options(self) errno = subprocess.call([sys.executable, '-m', 'pytest', 'tests'])
self.pytest_args = [] raise SystemExit(errno)
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
with codecs.open(os.path.join(os.path.abspath(os.path.dirname( with codecs.open(os.path.join(os.path.abspath(os.path.dirname(
@ -37,7 +27,7 @@ with codecs.open(os.path.join(os.path.abspath(os.path.dirname(
def read(f): def read(f):
return open(os.path.join(os.path.dirname(__file__), f)).read().strip() return open(os.path.join(os.path.dirname(__file__), f)).read().strip()
install_requires = ['aiohttp>=0.14'] install_requires = ['aiohttp>=0.18']
tests_require = install_requires + ['pytest'] tests_require = install_requires + ['pytest']
extras_require = {} extras_require = {}