Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Authentication library for aiohttp

Project description

Python 3.6 pypi travis-badge coveralls codefactor grade downloads

aegis allows to protect endpoints and also provides authentication scoping.


pip install aegis

Simple Example

from aiohttp import web
from aegis import login_required, JWTAuth

class JWTAuthenticator(JWTAuth):
    jwt_secret = "<secret>"

    async def authenticate(self, request: web.Request) -> dict:
        db =["db"]
        credentials = await request.json()
        id_ = credentials["id"]
        user = db.get(id_)
        return user

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

def create_app():
    app = web.Application()
    app["db"] = {
        5: {
            "name": "test"
    app.router.add_get('/protected', protected)


    return app

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

Get access token

curl -X POST -d '{"id": 5}'

{"access_token": "<access_token>"}

Get user

curl -H 'Authorization: Bearer <access_token>'

{'hello': 'user'}


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.

Filename, size & hash SHA256 hash help File type Python version Upload date
aegis-1.0.0.tar.gz (8.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page