Comments (4)
I have no knowledge whatsoever with Blackbox, but I'd be interested to tackle this.
from blackbox.
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.
from blackbox.
Alright sir, i'd happily take this then!
from blackbox.
@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 subscriber
should be lambda API
but the problem is that we don't know how auth
is implemented for this api, it could be thourgh HTTP headers
, in the request's body
under a specific key, in the query parameters
or maybe it doesn't even have auth
for all that we know.
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 type
can either be header
, body
or query-params
(The naming can be discussed obviously)
Then depending on that type, we'll know where we can put the credentials.
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 POST
requests, so maybe that should be held into account as well ?
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.
from blackbox.
Related Issues (20)
- Simplify semantic versioning logics HOT 2
- Notifier: SMTP HOT 2
- Poor UX when cooldown is missing
- Tag all releases with major and minor versions on DockerHub
- Allow specifying format for upload files to S3 HOT 1
- Feature Request: Support Backblaze B2 Storage HOT 3
- Feature Request: Encrypted Backups HOT 1
- Blackbox fails to send error notification if failure reason field is over Discord embed limit HOT 3
- Blackbox does not exit with status code 1 when a database has failed HOT 1
- Add pytest-testdox
- Lint the docstrings! HOT 2
- Telegram one Storage failed representation
- Database: Zip folder archiving
- Use temporary files to save dumps
- Add encryption to the saved dumps
- Support for multiple Postgres versions HOT 1
- Reduce line-length in tox.ini to 100, fix any problems that emerge.
- Stateless cooldown system
- Blackbox crashes when no cooldown is defined. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blackbox.