Skip to content

Commit

Permalink
removed key and added TODO for docusign auth
Browse files Browse the repository at this point in the history
  • Loading branch information
gcarvellas committed Nov 1, 2023
1 parent e3b5d0d commit 2743f04
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ async def after_request(request: Request, call_next: Callable[..., Awaitable[_St
response: Response = await call_next(request)
timestamp = strftime('[%Y-%b-%d %H:%M]') # TODO this is defined in multiple spots. Make robust
assert request.client, "Missing header data in request. No client information."
# TODO hide "key" query params
logging.info('%s %s %s %s %s %s', timestamp, request.client.host, request.method, request.scope['type'], request.url, response.status_code)
return response

Expand Down
1 change: 0 additions & 1 deletion src/config/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ def load_env(input: str) -> str:
DOCUSIGN_IMPERSONATED_USER_ID: str = load_env("DOCUSIGN_IMPERSONATED_USER_ID")
DOCUSIGN_PRIVATE_KEY: str = load_env("DOCUSIGN_PRIVATE_KEY")
CONTRACT_TEMPLATE_ID: str = load_env("CONTRACT_TEMPLATE_ID")
DOCUSIGN_QUERY_PARAM_KEY: str = load_env("WEBHOOK_QUERY_PARAM_KEY")
DOCUSIGN_API_VERSION: str = load_env("DOCUSIGN_API_VERSION")
9 changes: 3 additions & 6 deletions src/controllers/docusign_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ def __init__(self, auth: Cognito): # type: ignore[no-any-unimported]
super().__init__(auth)
self.router.add_api_route("/docusign/webhook", self.post, methods=["POST"], response_model=None)

def post(self, key: str, item: PostItem) -> Response:
def post(self, item: PostItem) -> Response:
mgr = DocusignWebhookManager()
if not mgr.is_webhook_key(key):
return JSONResponse(
status_code=status.HTTP_403_FORBIDDEN,
content=None
)

# TODO Include Docusign HMAC Signature and OAUTH

if item.api_version != DOCUSIGN_API_VERSION:
logging.warn(f"Webhook API Version doesn't match. Current: {item.api_version}, Expected: {DOCUSIGN_API_VERSION}")
Expand Down
4 changes: 0 additions & 4 deletions src/managers/docusign_webhook.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
from config.env import DOCUSIGN_QUERY_PARAM_KEY
from utilities.types.fields import DocusignWebhookEventEnum
from datetime import datetime
from typing import Dict, Any


class DocusignWebhookManager():

def is_webhook_key(self, key: str) -> bool:
return key == DOCUSIGN_QUERY_PARAM_KEY

def handle_webhook_event(self, event: DocusignWebhookEventEnum, retry_count: int, generated_date_time: datetime, data: Dict[str, Any]) -> None:
match event:
case DocusignWebhookEventEnum.envelope_created:
Expand Down
4 changes: 1 addition & 3 deletions tools/simulate-webhook/simulate_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
event_directory = f"../../docs/docusign-events/{event_folder_name}"
events = sorted(os.listdir(event_directory))

key = os.environ.get('WEBHOOK_QUERY_PARAM_KEY')

url = f"{server_ip}/docusign/webhook?key={key}"
url = f"{server_ip}/docusign/webhook"

headers = {
'Content-Type': 'application/json',
Expand Down

0 comments on commit 2743f04

Please sign in to comment.