skillfed

aiohttp-basicauth

Proxy connector for aiohttp

aiohttp-basicauth v1.2.0 78.1K downloads/30d#14,471 on PyPI18
Permissive license Apache-2.0 Active released

What it is and what it does

aiohttp-basicauth is a middleware for aiohttp that adds HTTP basic authentication to your async web application. It intercepts requests and validates credentials against a username and password you provide, returning an error response if authentication fails. You can apply it globally to all routes or selectively to specific views using a decorator.

The package is lightweight and depends only on aiohttp. It supports both simple static credentials and custom verification logic by subclassing and overriding the check_credentials method, making it suitable for scenarios ranging from development servers to applications with dynamic user stores.

Use it for:

  • Protect all routes in a development or internal API with a single username and password
  • Selectively require authentication on specific endpoints while leaving others public
  • Implement custom authentication logic by subclassing and querying a database for user credentials
  • Add basic auth to microservices or internal tools that need simple credential validation

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides HTTP basic authentication middleware for aiohttp applications, allowing you to protect routes with username and password credentials.

Yes. The package is actively maintained, has no known vulnerabilities, installs with low friction, and solves a straightforward problem for aiohttp users. Use it when you need basic HTTP authentication without the complexity of OAuth or session management.

Install

aiohttp-basicauth on PyPI

pip

pip install aiohttp-basicauth

uv

uv add aiohttp-basicauth

poetry

poetry add aiohttp-basicauth

Installing aiohttp-basicauth

Before you install

Low friction installation with a single dependency on aiohttp. Actively maintained with recent releases and a stable codebase.

License in practice

Apache-2.0 is permissive; you can use this package freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install aiohttp-basicauth

from aiohttp import web
from aiohttp_basicauth import BasicAuthMiddleware

auth = BasicAuthMiddleware(username='user', password='password')
app = web.Application(middlewares=[auth])
web.run_app(app, host='127.0.0.1', port=80)

Requires aiohttp >= 3.10 and Python >= 3.8

Verify before relying

  • Whether the package supports custom credential backends (e.g., database lookups) beyond the check_credentials override pattern shown in the description
  • What HTTP status code is returned when authentication fails

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.8.0)
Install friction low — pure-Python wheel
Runtime dependencies 1 — aiohttp
Maintenance actively maintained — 70 days since the last release
Last repo commit
First released
Downloads 78,062/month — #14,471 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: aiohttp_basicauth-1.2.0-py3-none-any.whl

Keywords: asyncio, aiohttp, http, auth, basic auth

Development Status :: 4 - BetaFramework :: AsyncIOIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOSOperating System :: MicrosoftOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTP

Tags

aiohttp basic auth middlewarehttp basic authentication asyncaiohttp route protectionbasic auth aiohttpasync http authentication
authenticationmiddleware

More WWW/HTTP packages