aliev / aioauth

Asynchronous OAuth 2.0 provider for Python 3
https://aliev.me/aioauth
MIT License
214 stars 19 forks source link

minimum viable fastapi aioauth example #107

Open imgurbot12 opened 11 hours ago

imgurbot12 commented 11 hours ago

created based on discussion in https://github.com/aliev/aioauth/pull/106

aliev commented 2 hours ago

Thanks!

I have a few ideas if you don’t mind.

Ability to load fixtures and configuration during startup

To facilitate the process of setting up the model's data (clients, users, etc), we could provide the configuration file support. The configuration file might look like this:

cat config.json
{
    "fixtures": {
        "users": {"id": "...", "username": "...", ...},
        "clients": {...},
        ...
    },
    "settings": {"INSECURE_TRANSPORT": true, ...}
}

(I was thinking about yaml, but I think it requires additional dependency)

this way fixtures will be automatically loaded into the memory database before the server starts.

python -m examples/fastapi_example.py # Loads the config.json fixture from the current directory

Making package out of the examples

I suggest creating a python package in examples with a pyproject.toml file for now. The directory and file structure would look like this:

examples/fastapi/__init__.py
examples/fastapi/__main__.py
examples/fastapi/pyproject.toml
...

Making sure that formatting is consistent

Could you apply pre-commit and check if there are any formatting fixes needed? Just run the command: pre-commit run --all-files