Skip to main content
https://travis-ci.org/bugov/aiohttp-basicauth-middleware.svg?branch=master

Aiohttp middleware for simple http basic auth protection for some urls.

Works with Python >= 3.6.

Works with UTF-8 🖖

Installation

pip install aiohttp-basicauth-middleware

Usage

app = web.Application(loop=loop)

app.router.add_route('GET', '/hello', handler_a)
app.router.add_route('GET', '/admin/hello', handler_b)

app.middlewares.append(
    basic_auth_middleware(
        ('/admin',),
        {'user': 'password'},
    )
)

basic_auth_middleware has 3 params:

  1. list of protected urls. For example [‘/admin’] will match with /admin/user, but will not match with /user/admin.

  2. auth dict – a dict with pairs: login-password.

  3. strategy (optional) for password comparision. For example you can store hashed password in auth_dict. See aiohttp_basicauth_middleware.strategy.BaseStrategy and example.strategy for more information.

Example with md5 password hashing:

app = web.Application(loop=loop)

app.router.add_route('GET', '/hello', handler_a)
app.router.add_route('GET', '/admin/hello', handler_b)

app.middlewares.append(
    basic_auth_middleware(
        ('/admin',),
        {'user': '5f4dcc3b5aa765d61d8327deb882cf99'},
        lambda x: hashlib.md5(bytes(x, encoding='utf-8')).hexdigest(),
    )
)

/admin/… will be accessed by the same login+password pair (‘user’, ‘password’).

Metadata

Release files for aiohttp-basicauth-middleware 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttp-basicauth-middleware 1.2.0
File Size Uploaded Provenance Actions
aiohttp-basicauth-middleware-1.2.0.tar.gz 4.7 kB Without provenance Details for aiohttp-basicauth-middleware-1.2.0.tar.gz

Release files / aiohttp-basicauth-middleware-1.2.0.tar.gz

Download URL aiohttp-basicauth-middleware-1.2.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d21dadf4a839be6ceddff0fbce74f678b5e4c3e4a6177d431c69b662f77922d3
BLAKE2b-256 checksum
How to use checksums
0582a4dafcf373255b764e23d590c5aa35938e8b54d350c760fe29f88706bbb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Security for aiohttp-basicauth-middleware 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page