-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
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
- Added S2Pairing implementation #85 (first implementation of S2 pairing)
- Dependency on websockets #72 (optional WS dependencies)
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)- 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.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
try:
import fastapi
except ImportError:
raise ImportError("You need to run 'pip install s2-python[fastapi]' to use this feature.")
In pyproject.tomlsetup.cfg:
[project.optional-dependencies]
fastapi =
fastapi
flask =
Flask
Metadata
Metadata
Assignees
Labels
No labels