From 494f1c98266d60bcc9c1b1e3ca7f94b27902217f Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 8 Dec 2022 23:55:01 -0500 Subject: [PATCH] add skeleton of endpoint to receive github webhooks --- .../src/spiffworkflow_backend/api.yml | 14 ++++++++++++++ .../routes/process_api_blueprint.py | 11 +++++++++++ .../services/authorization_service.py | 6 +++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml index d4ed3755d..f5836d632 100755 --- a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml @@ -490,6 +490,20 @@ paths: items: $ref: "#/components/schemas/Process" + /github-webhook-receive: + post: + operationId: spiffworkflow_backend.routes.process_api_blueprint.github_webhook_receive + summary: receives push webhooks from github so we can keep our process model repo up to date + tags: + - git + responses: + "200": + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/OkTrue" + /process-instances: parameters: - name: process_model_identifier diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index b4437ef8b..c58e6d55c 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -1816,9 +1816,20 @@ def get_spiff_task_from_process_instance( return spiff_task +# sample body: +# {'ref': 'refs/heads/main', 'repository': {'name': 'sample-process-models', +# 'full_name': 'sartography/sample-process-models', 'private': False .... }} +def github_webhook_receive(body: dict) -> Response: + """Github_webhook_receive.""" + print(f"body: {body}") + return Response(json.dumps({"ok": True}), status=200, mimetype="application/json") + + # # Methods for secrets CRUD - maybe move somewhere else: # + + def get_secret(key: str) -> Optional[str]: """Get_secret.""" return SecretService.get_secret(key) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py index bde408308..511d138eb 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py @@ -232,7 +232,11 @@ class AuthorizationService: def should_disable_auth_for_request(cls) -> bool: """Should_disable_auth_for_request.""" swagger_functions = ["get_json_spec"] - authentication_exclusion_list = ["status", "authentication_callback"] + authentication_exclusion_list = [ + "status", + "authentication_callback", + "github_webhook_receive", + ] if request.method == "OPTIONS": return True