-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notifier: Plain JSON webhook #108
Comments
I have no knowledge whatsoever with Blackbox, but I'd be interested to tackle this. |
Hi @shtlrs! I'm happy to let you take a crack at it if you'd like. If you get stuck, poke me on Discord in https://discord.gg/hc5pDWNNzx in the #blackbox channel and I'll try to help. |
Alright sir, i'd happily take this then! |
@lemonsaurus Very sorry, I had completely forgotten about this, it got filtered out because i've set the org to pydis. So I was running through the code to see how it all works and I was wondering how we'd want to handle auth for this. The This got me thinking into how we'd want to implement this in the most simple way, so how about this notifiers:
json:
my-api:
url: https://mydomain.com/api/v1/database-updates/
auth:
type: headers
key: key
value: value
method: 'POST' The For example from requests import Request, Session
class Json(BlackboxNotifier):
....
def notify(self) -> None:
"""Send a webhook to Slack with a blackbox report."""
request = Request(
method=self.config["method"],
url=self.config["url"],
)
auth = self.config.get("auth", {"type": "none", "key": "none", "value": "none"})
auth_key = auth["key"]
auth_value = auth["value"]
auth_type = auth["type"]
payload = self.method_to_construct_request_payload()
request.json = payload
if auth_type == "headers":
request.headers = {auth_key: auth_value}
if auth_type == "body":
payload[auth_key] = auth_value
if auth_type == "query-params":
request.params[auth_key] = auth_value
with Session() as session:
session.send(request=request.prepare()) As I'm writing this, it also occured to me that we cannot even guarantee that the endpoint would solely take I know that auth for webhooks usually doesn't take place like this and that the end sending the event/request would include some sort of signature in the headers that needs to be validated by combining the request's body and some secret then hashing them etc etc, but I also don't believe that we can achieve that here. |
We currently allow blackbox to send out various bespoke webhooks, like Discord and Slack, but let's also make a dead simple plain JSON webhook so that people can implement notifications on arbitrary, generic platforms, or in their own applications.
Use the simplest JSON structure possible.
The text was updated successfully, but these errors were encountered: