Repository navigation
Expand file tree
/
Copy pathwebhook.py
More file actions
45 lines (39 loc) · 1.4 KB
/
Copy pathwebhook.py
File metadata and controls
45 lines (39 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import typing
from enum import Enum
from typing import Union
from opal_common.schemas.policy import BaseSchema
from pydantic import Field
class SecretTypeEnum(str, Enum):
"""Is the passed secret in the webhook a token or a signature on the
request body."""
token = "token"
signature = "signature"
class GitWebhookRequestParams(BaseSchema):
secret_header_name: str = Field(
...,
description="The HTTP header holding the secret",
)
secret_type: SecretTypeEnum = Field(
...,
description=SecretTypeEnum.__doc__,
)
secret_parsing_regex: str = Field(
...,
description="The regex used to parse out the actual signature from the header. Use '(.*)' for the entire value",
)
event_header_name: typing.Optional[str] = Field(
default=None,
description="The HTTP header holding the event information (used instead of event_request_key)",
)
event_request_key: typing.Optional[str] = Field(
default=None,
description="The JSON object key holding the event information (used instead of event_header_name)",
)
push_event_value: str = Field(
...,
description="The event value indicating a Git push",
)
match_sender_url: bool = Field(
True,
description="Should OPAL verify that the sender url matches the tracked repo URL, and drop the webhook request otherwise?",
)