Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
43f59a21fc |
40
.github/workflows/ci.yaml
vendored
40
.github/workflows/ci.yaml
vendored
@@ -1,40 +0,0 @@
|
|||||||
name: Tests
|
|
||||||
|
|
||||||
on: pull_request
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
name: Tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
continue-on-error: ${{ matrix.experimental }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version:
|
|
||||||
- 3.6
|
|
||||||
- 3.7
|
|
||||||
- 3.8
|
|
||||||
- 3.9
|
|
||||||
experimental: [false]
|
|
||||||
include:
|
|
||||||
- python-version: 3.10.0-alpha - 3.10.0
|
|
||||||
experimental: true
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
pip install --upgrade pip
|
|
||||||
pip install -r requirements-dev.txt
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
|
||||||
make coverage
|
|
||||||
- name: Upload coverage
|
|
||||||
uses: codecov/codecov-action@v1
|
|
||||||
with:
|
|
||||||
file: ./coverage.xml
|
|
||||||
flags: unit
|
|
31
.github/workflows/pypi.yml
vendored
31
.github/workflows/pypi.yml
vendored
@@ -1,31 +0,0 @@
|
|||||||
name: Publish to PyPI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags: [ 'v*' ]
|
|
||||||
|
|
||||||
env:
|
|
||||||
DEFAULT_PYTHON: 3.9
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
name: Publish to PyPI
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: ${{ env.DEFAULT_PYTHON }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
pip install --upgrade build
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
python -m build
|
|
||||||
- name: Publish to PyPI
|
|
||||||
uses: pypa/gh-action-pypi-publish@master
|
|
||||||
with:
|
|
||||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
33
.travis.yml
Normal file
33
.travis.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
language: python
|
||||||
|
python:
|
||||||
|
- 3.5
|
||||||
|
- 3.6
|
||||||
|
- 3.7
|
||||||
|
- nightly
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
allow_failures:
|
||||||
|
- python: 3.7-dev
|
||||||
|
- python: nightly
|
||||||
|
|
||||||
|
install:
|
||||||
|
- pip install --upgrade pip
|
||||||
|
- pip install -r requirements-dev.txt
|
||||||
|
- pip install codecov
|
||||||
|
|
||||||
|
script:
|
||||||
|
- make coverage
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- codecov
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
provider: pypi
|
||||||
|
user: aio-libs-bot
|
||||||
|
password:
|
||||||
|
secure: "fHbpT6AuRM+K6hg0nWT7ov/qJAAFJ7N5Mot1Z02QVHv9+XXJsqSmzJHMyv4FNWSO+IG9ulJ/wrVpQ/wr5S1FiCVJYpMFJP/71fqT7MbrgUg+ovbGrs1AfJHHQtVc91Az9Yl2nP+wzJCplJIuxO8IVjKHS87QxupzMHapo97ItYM6yvCNzIP+3JjvZyl5/ocqdUpl4KiS/tzXbiaBSlVgmI/013EbD5U36wcz2AAszTcBzKTDJh0BF4wr4brHnVPKr4gRSZPZRYduZ7WXh0rJt/aGyNGm9siYkKhuE+pzd/6vIbN3keKEhAjafCl4+Z3a0eL0ACyt8CBCBHf9/n4KYm+KPwLe3NYWKkO6qCJpZ+bMNfQInKiEoWJx9KDaKjdCVivlKY+abaJiF/thO4udunn3PfPz2O8MlkZRoTVqASN1sP60cULTlxfLi8x0RVqMKIHejNQi/AN8/4poCPFfFOOia/WQqq1pD45vJh8pNxsc6IEAjhHUgvMDnK0DBkEs4i2catZKc2YPEjgAkvplvTE4tH8Tzyj5EvMwM56h2zfByeKs9ojkvzyhPLhWq7d8JTPWPAyj72FsrpGm12cLU/E9g9KKj6Hg5E3F0+V2Zs7wXc+fT1ovC5/NRL2WpT2+k1wF/9Q7ZrbQ9InunHXYU7GJCFzRE8XlcRsBGPcR3Ls="
|
||||||
|
distributions: "sdist bdist_wheel"
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
all_branches: true
|
||||||
|
python: 3.7
|
2
Makefile
2
Makefile
@@ -11,7 +11,7 @@ vtest: flake
|
|||||||
py.test -s ./tests/
|
py.test -s ./tests/
|
||||||
|
|
||||||
cov cover coverage: flake
|
cov cover coverage: flake
|
||||||
py.test -s ./tests/ --cov=aiohttp_security --cov=tests --cov-report=html --cov-report=xml --cov-report=term
|
py.test -s ./tests/ --cov=aiohttp_security --cov=tests --cov-report=html --cov-report=term
|
||||||
@echo "open file://`pwd`/coverage/index.html"
|
@echo "open file://`pwd`/coverage/index.html"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@@ -15,11 +15,12 @@ AUTH_SCHEME = 'Bearer '
|
|||||||
|
|
||||||
|
|
||||||
class JWTIdentityPolicy(AbstractIdentityPolicy):
|
class JWTIdentityPolicy(AbstractIdentityPolicy):
|
||||||
def __init__(self, secret, algorithm='HS256'):
|
def __init__(self, secret, algorithm='HS256', key: str = 'login'):
|
||||||
if jwt is None:
|
if jwt is None:
|
||||||
raise RuntimeError('Please install `PyJWT`')
|
raise RuntimeError('Please install `PyJWT`')
|
||||||
self.secret = secret
|
self.secret = secret
|
||||||
self.algorithm = algorithm
|
self.algorithm = algorithm
|
||||||
|
self.key = key
|
||||||
|
|
||||||
async def identify(self, request):
|
async def identify(self, request):
|
||||||
header_identity = request.headers.get(AUTH_HEADER_NAME)
|
header_identity = request.headers.get(AUTH_HEADER_NAME)
|
||||||
@@ -36,7 +37,7 @@ class JWTIdentityPolicy(AbstractIdentityPolicy):
|
|||||||
identity = jwt.decode(token,
|
identity = jwt.decode(token,
|
||||||
self.secret,
|
self.secret,
|
||||||
algorithms=[self.algorithm])
|
algorithms=[self.algorithm])
|
||||||
return identity
|
return identity.get(self.key)
|
||||||
|
|
||||||
async def remember(self, *args, **kwargs): # pragma: no cover
|
async def remember(self, *args, **kwargs): # pragma: no cover
|
||||||
pass
|
pass
|
||||||
|
@@ -13,6 +13,6 @@ aioredis==1.3.1
|
|||||||
hiredis==1.1.0
|
hiredis==1.1.0
|
||||||
passlib==1.7.4
|
passlib==1.7.4
|
||||||
cryptography==3.3.1
|
cryptography==3.3.1
|
||||||
aiohttp<3.7
|
aiohttp==3.7.3
|
||||||
pytest-aiohttp==0.3.0
|
pytest-aiohttp==0.3.0
|
||||||
pyjwt==1.7.1
|
pyjwt==1.7.1
|
||||||
|
@@ -2,4 +2,3 @@
|
|||||||
testpaths = tests
|
testpaths = tests
|
||||||
filterwarnings=
|
filterwarnings=
|
||||||
error
|
error
|
||||||
ignore:The loop argument:DeprecationWarning
|
|
||||||
|
@@ -43,7 +43,7 @@ async def test_identify(loop, make_token, aiohttp_client):
|
|||||||
async def check(request):
|
async def check(request):
|
||||||
policy = request.app[IDENTITY_KEY]
|
policy = request.app[IDENTITY_KEY]
|
||||||
identity = await policy.identify(request)
|
identity = await policy.identify(request)
|
||||||
assert 'Andrew' == identity['login']
|
assert 'Andrew' == identity
|
||||||
return web.Response()
|
return web.Response()
|
||||||
|
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
|
Reference in New Issue
Block a user