crim-ca / weaver

Weaver: Workflow Execution Management Service (EMS); Application, Deployment and Execution Service (ADES); OGC API - Processes; WPS; CWL Application Package
https://pavics-weaver.readthedocs.io
Apache License 2.0
23 stars 6 forks source link

Fix typing for other auth handlers in CLI #628

Closed fmigneault closed 1 month ago

fmigneault commented 1 month ago

Describe the bug

Typing of AuthHandler on auth parameter for the WeaverClient do not permit other/external handlers.

How to Reproduce

import os
from requests_magpie import MagpieAuth
from weaver.cli import WeaverClient

client = WeaverClient(
    url="https://hirondelle.crim.ca/weaver/",
    auth=MagpieAuth(
        magpie_url="https://hirondelle.crim.ca/magpie/",
        username=os.getenv("MAGPIE_USERNAME"),
        password=os.getenv("MAGPIE_PASSWORD"),
    )
)

image

Expected behavior

A Protocol (or other similar?) typing definition should be used to allow any AuthHandler-like implementation that provides all necessary parameters and operations. Namely, that would be the __call__ method that must set the relevant HTTP method, headers, etc. definitions based on the provided request object as input.