Skip to main content

Authentication library for aiohttp

Project description

Python 3.6 travis-badge coveralls codefactor grade

aegis allows to protect endpoints and also provides authentication scoping.


pip install aegis

Simple Example

# examples/
from aiohttp import web
from aegis import auth
from aegis.authenticators.jwt import JWTAuth

    'david': {'id': 5, 'scopes': ('user',)}

class MyAuth(JWTAuth):
    jwt_secret = "test"

    async def authenticate(self, request: web.Request) -> dict:
        payload = await request.json()
        user = DATABASE.get(payload['username'])
        return user

async def public(request):
    return web.json_response({'hello': 'anonymous'})

async def protected(request):
    return web.json_response({'hello': 'user'})

def create_app():
    app = web.Application()

    app.router.add_get('/public', public)
    app.router.add_get('/protected', protected)

    return app

if __name__ == '__main__':
    app = create_app()

Get access token

curl -X POST -d '{"username": "david"}'

{"access_token": "<access_token>"}

Get user

curl -H 'Authorization: Bearer <access_token>'

{"id": 5, "scopes": ["user"], "exp": 1553753859}


git clone
cd aegis
make cov


  • Python >= 3.6

  • aiohttp

  • PyJWT


aegis is offered under the Apache 2 license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aegis-0.3.1.tar.gz (7.7 kB view hashes)

Uploaded source

Built Distribution

aegis-0.3.1-py2.py3-none-any.whl (19.5 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page