diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa6c7f9..d893076 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,14 +24,14 @@ jobs: - name: Install dependencies run: | make dev-install - pip install codecov - name: Run lint run: | make lint - name: Run tests run: | make test - - name: Upload test coverage - run: codecov - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/Makefile b/Makefile index c6ceac4..6c858f1 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,8 @@ lint: ## check style with flake8 pre-commit run --all-files test: ## run tests quickly with the default Python - pytest tests + coverage run -m pytest tests + coverage xml -o junit.xml release: dist ## package and upload a release twine upload dist/* diff --git a/README.md b/README.md index 2a1801a..d2a7a8b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Coverage](https://badgen.net/codecov/c/github/aliev/aioauth)](https://app.codecov.io/gh/aliev/aioauth) [![License](https://img.shields.io/github/license/aliev/aioauth)](https://github.com/aliev/aioauth/blob/master/LICENSE) [![PyPi](https://badgen.net/pypi/v/aioauth)](https://pypi.org/project/aioauth/) -[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/) +[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/) `aioauth` implements [OAuth 2.0 protocol](https://tools.ietf.org/html/rfc6749) and can be used in asynchronous frameworks like [FastAPI / Starlette](https://github.com/tiangolo/fastapi), [aiohttp](https://github.com/aio-libs/aiohttp). It can work with any databases like `MongoDB`, `PostgreSQL`, `MySQL` and ORMs like [gino](https://python-gino.org/), [sqlalchemy](https://www.sqlalchemy.org/) or [databases](https://pypi.org/project/databases/) over simple [BaseStorage](aioauth/storage.py) interface. diff --git a/docs/source/conf.py b/docs/source/conf.py index 426224d..8a2c900 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,20 +1,22 @@ # -- Path setup -------------------------------------------------------------- from pathlib import Path +import tomllib +from aioauth import __version__ # Project root folder. root = Path(__file__).parent.parent.parent # Loads __version__ file. about = {} -with open(root / "aioauth" / "__version__.py", "r") as f: - exec(f.read(), about) +with open(root / "pyproject.toml", "rb") as f: + about = tomllib.load(f) # -- Project information ----------------------------------------------------- -project = about["__title__"] -author = about["__author__"] -release = about["__version__"] +project = about["project"]["description"] +author = about["project"]["authors"][0]["name"] +release = __version__ # -- General configuration --------------------------------------------------- diff --git a/docs/source/contents.rst b/docs/source/contents.rst index 9eb2ab2..92b125e 100644 --- a/docs/source/contents.rst +++ b/docs/source/contents.rst @@ -15,20 +15,6 @@ :glob: :maxdepth: 2 - sections/using/* - -.. toctree:: - :caption: Examples - :glob: - :maxdepth: 2 - - sections/examples/* - -.. toctree:: - :caption: Documentation - :glob: - :maxdepth: 3 - sections/documentation/* .. toctree:: diff --git a/docs/source/index.rst b/docs/source/index.rst index 1ccef20..aa73431 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -33,7 +33,7 @@ aioauth supports the following RFCs: Pages ----- -* `Github Project `_ +* `Github Project `_ * `Issues `_ * `Discussion `_ diff --git a/docs/source/sections/examples/aiohttp.rst b/docs/source/sections/examples/aiohttp.rst deleted file mode 100644 index fce8490..0000000 --- a/docs/source/sections/examples/aiohttp.rst +++ /dev/null @@ -1,2 +0,0 @@ -Aiohttp -======= diff --git a/docs/source/sections/examples/fastapi.rst b/docs/source/sections/examples/fastapi.rst deleted file mode 100644 index 2deda94..0000000 --- a/docs/source/sections/examples/fastapi.rst +++ /dev/null @@ -1,58 +0,0 @@ -FastAPI -======= - -Installing ----------- - -To install aioauth with FastAPI at the command line: - -.. code-block:: - - $ pip install aioauth[fastapi] - -Usage example - -.. code-block:: python - - from dataclasses import dataclasses - from aioauth_fastapi.router import get_oauth2_router - from aioauth.storage import BaseStorage - from aioauth.requests import BaseRequest, Query, Post - from aioauth.models import AuthorizationCode, Client, Token - from aioauth.config import Settings - from aioauth.server import AuthorizationServer - from fastapi import FastAPI - - app = FastAPI() - - @dataclasses - class User: - """Custom user model""" - first_name: str - last_name: str - - - class Request(BaseRequest[Query, Post, User]): - """Custom Request model""" - - - class Storage(BaseStorage[Token, Client, AuthorizationCode, Request]): - """ - Storage methods must be implemented here. - """ - - storage = Storage() - authorization_server = AuthorizationServer[Request, Storage](storage) - - # NOTE: Redefinition of the default aioauth settings - # INSECURE_TRANSPORT must be enabled for local development only! - settings = Settings( - INSECURE_TRANSPORT=True, - ) - - # Include FastAPI router with oauth2 endpoints. - app.include_router( - get_oauth2_router(authorization_server, settings), - prefix="/oauth2", - tags=["oauth2"], - ) diff --git a/docs/source/sections/using/configuration.rst b/docs/source/sections/using/configuration.rst deleted file mode 100644 index b592e7a..0000000 --- a/docs/source/sections/using/configuration.rst +++ /dev/null @@ -1,48 +0,0 @@ -Configuration -============= - -All aioauth settings are made through :py:class:`aioauth.config.Settings` class. - -Defaults - -+----------------------------------------+---------------+----------------------------------------------------------------+ -| Setting | Default value | Description | -| | | | -+========================================+===============+================================================================+ -| TOKEN_EXPIRES_IN | 86400 | Access token lifetime. | -+----------------------------------------+---------------+----------------------------------------------------------------+ -| AUTHORIZATION_CODE_EXPIRES_IN | 300 | Authorization code lifetime. | -+----------------------------------------+---------------+----------------------------------------------------------------+ -| INSECURE_TRANSPORT | False | Allow connections over SSL only. When this option is disabled | -| | | server will raise "HTTP method is not allowed" error. | -+----------------------------------------+---------------+----------------------------------------------------------------+ - -the default settings can be changed as follows: - -.. code-block:: python - - import os - from aioauth.config import Settings - - settings = Settings( - INSECURE_TRANSPORT=not os.getenv('DEBUG', False) - ) - -this example disables checking for insecure transport, depending on the debug mode of the current environment. - -The :py:class:`aioauth.requests.Request` consumes an instance of the :py:class:`aioauth.config.Settings` class: - -.. code-block:: python - - import os - from aioauth.config import Settings - from aioauth.requests import Request - - settings = Settings( - INSECURE_TRANSPORT=not os.getenv('DEBUG', False) - ) - - request = Request( - settings=settings, - ... - ) diff --git a/docs/source/sections/using/server_database.rst b/docs/source/sections/using/server_database.rst deleted file mode 100644 index 30f7304..0000000 --- a/docs/source/sections/using/server_database.rst +++ /dev/null @@ -1,2 +0,0 @@ -Server & Database -=================