Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
!.travis.yml
__pycache__
*.egg-info

/build
/.idea
/htmlcov
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
language: python
python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
install:
- pip install -r requirements.txt
- pip install .
script:
- python setup.py test
- python -m pytest

4 changes: 0 additions & 4 deletions CODE_OF_CONDUCT.md

This file was deleted.

24 changes: 0 additions & 24 deletions LICENSE

This file was deleted.

7 changes: 7 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2025 Georgy Bazhukov <georgy.bazhukov@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
Aiohttp middleware for simple http basic
auth protection for some urls.

Works with Python ≥ 3.6.
Works with
- Python ≥ 3.6 (till version 1.2.*);
- Python ≥ 3.10 (from version 1.3.0);

Works with UTF-8 🖖

Expand Down Expand Up @@ -36,9 +38,9 @@ app.middlewares.append(
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
3. strategy (optional) for password comparison. For example you can
store hashed password in `auth_dict`. See `aiohttp_basicauth_middleware.strategy.BaseStrategy` and
`example.strategy` for more information.
`tests.example.strategy` for more information.

Example with md5 password hashing:

Expand Down
65 changes: 0 additions & 65 deletions README.rst

This file was deleted.

2 changes: 1 addition & 1 deletion aiohttp_basicauth_middleware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def check_access(
def basic_auth_middleware(
urls: Iterable,
auth_dict: dict,
strategy: Type[BaseStrategy] = lambda x: x
strategy: Type[BaseStrategy] | Callable = lambda x: x
) -> Coroutine:
async def factory(app, handler) -> Coroutine:
async def middleware(request) -> web.Response:
Expand Down
47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[build-system]
requires = ["setuptools >= 42.0.0"]
build-backend = "setuptools.build_meta"

[project]
name = "aiohttp-basicauth-middleware"
version = "1.3.0"
dependencies = [
"http_basic_auth",
"aiohttp",
]
requires-python = ">=3.10"
authors = [
{name = "Georgy Bazhukov", email = "georgy.bazhukov@gmail.com"},
]
maintainers = [
{name = "Georgy Bazhukov", email = "georgy.bazhukov@gmail.com"},
]
description = "An incredibly simple HTTP basic auth implementation for Aiohttp."
readme = "README.md"
license = "MIT"
license-files = ["LICEN[CS]E.*"]
keywords = ["aiohttp", "security", "basicauth", "http", "middleware"]
classifiers = [
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
]

[project.optional-dependencies]
dev = [
"pytest>=6.0.0",
"pytest-cov>=6.0.0",
"black",
"flake8",
"tox"
]

[project.urls]
Homepage = "https://github.com/bugov/aiohttp-basicauth-middleware"
Repository = "https://github.com/bugov/aiohttp-basicauth-middleware.git"
"Bug Tracker" = "https://github.com/bugov/aiohttp-basicauth-middleware/issues"
6 changes: 0 additions & 6 deletions requirements-dev.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

49 changes: 0 additions & 49 deletions setup.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Empty file added tests/example/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion example/server.py → tests/example/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from aiohttp_basicauth_middleware import basic_auth_middleware


def hello(request):
async def hello(request):
return web.Response(text='Hello')


Expand Down
2 changes: 1 addition & 1 deletion example/strategy.py → tests/example/strategy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
from aiohttp import web
from aiohttp_basicauth_middleware import basic_auth_middleware
from aiohttp_basicauth_middleware.strategy import BaseStrategy
from aiohttp_basicauth_middleware import BaseStrategy


class SkipOptionsStrategy(BaseStrategy):
Expand Down
2 changes: 1 addition & 1 deletion test/test_middleware.py → tests/test_middleware.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hashlib
from http_basic_auth import generate_header

from example.server import get_app
from test.example.server import get_app


async def test_no_auth_ok_url(aiohttp_server, aiohttp_client, loop):
Expand Down
2 changes: 1 addition & 1 deletion test/test_strategy.py → tests/test_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from aiohttp_basicauth_middleware import basic_auth_middleware
from http_basic_auth import generate_header

from example.strategy import get_app
from test.example.strategy import get_app


async def test_skip_options_check(aiohttp_server, aiohttp_client, loop):
Expand Down
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
[tox]
skipsdist = True
envlist = py36, py37, py38, py39, py310
envlist = py310, py311, py312, py313, p314

[testenv]
deps= -r{toxinidir}/requirements-dev.txt
deps =
aiohttp
http_basic_auth
commands =
pytest -x --cov=aiohttp_basicauth_middleware --no-cov-on-fail
pytest --cov=aiohttp_basicauth_middleware --cov-report=html
coverage html --fail-under=100
setenv =
LANG = ru_RU.UTF-8
PYTHONPATH = {toxinidir}
recreate = False
allowlist_externals =
pytest

[pep8]
max-line-length = 120
Expand Down