Skip to content

Repository structure for pairing & authentication #101

@Flix6x

Description

@Flix6x

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions