Goal
We wish to include working examples of the pairing and authentication process between client and server, while acknowledging that production implementations will likely want to integrate this process in their own application, using their own dependencies.
Approach
- Create abstract classes for client and server.
- Create subclasses for client and server using specific dependencies (e.g. FastAPI) that are not part of the default s2-python installation.
Related work
Proposed structure
Usable with pip install s2-python:
src/s2python/specification/s2-pairing/yml with the OpenAPI specification for the pairing & authentication process
src/s2python/generated/gen_s2_pairing.py with PairingRequest, etc.
src/s2python/authorization/
client.py with AbstractAuthClient
server.py with AbstractAuthServer
service.py with HTTPAuthServer(AbstractAuthServer)
- tbd:
AsyncAuthClient(AbstractAuthClient)?
Usable with pip install s2-python[ws]:
src/s2python/s2_connection.py (currently actually a RM in WS server mode?)
Usable with pip install s2-python[fastapi]:
src/s2python/authorization/fastapi_service.py with FastAPIAuthServer(AbstractAuthServer)
Usable with pip install s2-python[flask]:
src/s2python/authorization/flask_service.py with FlaskAuthServer(AbstractAuthServer)
In flexmeasures-s2 (installed with pip install flexmeasures-s2):
FlexMeasuresAuthServer(FlaskAuthServer)
Relevant code snippets
try:
import fastapi
except ImportError:
raise ImportError("You need to run 'pip install s2-python[fastapi]' to use this feature.")
In pyproject.toml setup.cfg:
[project.optional-dependencies]
fastapi =
fastapi
flask =
Flask
Goal
We wish to include working examples of the pairing and authentication process between client and server, while acknowledging that production implementations will likely want to integrate this process in their own application, using their own dependencies.
Approach
Related work
Proposed structure
Usable with
pip install s2-python:src/s2python/specification/s2-pairing/ymlwith the OpenAPI specification for the pairing & authentication processsrc/s2python/generated/gen_s2_pairing.pywithPairingRequest, etc.src/s2python/authorization/client.pywithAbstractAuthClientserver.pywithAbstractAuthServerservice.pywithHTTPAuthServer(AbstractAuthServer)AsyncAuthClient(AbstractAuthClient)?Usable with
pip install s2-python[ws]:src/s2python/s2_connection.py(currently actually a RM in WS server mode?)Usable with
pip install s2-python[fastapi]:src/s2python/authorization/fastapi_service.pywithFastAPIAuthServer(AbstractAuthServer)Usable with
pip install s2-python[flask]:src/s2python/authorization/flask_service.pywithFlaskAuthServer(AbstractAuthServer)In flexmeasures-s2 (installed with
pip install flexmeasures-s2):FlexMeasuresAuthServer(FlaskAuthServer)Relevant code snippets
In
pyproject.tomlsetup.cfg: