mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 00:35:51 +03:00
[GH-ISSUE #412] [Feature-request] Add validation token to hook and API requests #265
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#265
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @baiomys on GitHub (Dec 16, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/412
For instance telegram bot API uses X-Telegram-Bot-Api-Secret-Token passed in header.
It is user definable during webhook initialization.
Is it possible to implement same mechanism in API calls and maybe in webhook?
Most of interaction with API occurs on private networks, but sometimes it is necessary to expose REST endpoints.
Currently all path and header validation runs on reverse proxy side, which is a bit inconvenient.
@axllent commented on GitHub (Dec 20, 2024):
Sorry, I'm not ignoring you @baiomys - I've just been recovering after the operation ... and thinking about this. Your question is actually two-fold, first for webhook requests, and secondly incoming API requests. Currently neither is possible using tokens. I'm not saying I won't consider this, I would just like to understand your requirements better, as supporting like this becomes a huge change in how Mailpit works.
Webhooks
From what I can tell, the Telegram API allows a token to be set in either a header, or in the URL. Is there any reason you can't use it in the URL, or do I misunderstand the difference between a secret token and (regular?) token?
API
As far as authentication is (currently) concerned, both the web UI and the API are directly linked, and currently only supports basic authentication. If basic auth is set, then HTTP requests should be made in the form of
https://<user>:<pass>@example.com/api/v1/<endpoint>. Can the external bot service not use this syntax?When it comes to custom integrations (like what I think you are working towards), then you may have to consider a custom self written "proxy service" (PHP, Go, node server etc) that can receive requests from either end and then process / customize the data, and pass that on either way (
<Mailpit><-><proxy><-><Telegram>). This both limits your Mailpit exposure to the internet, and allows you the flexibility to do whatever you like without requiring both ends to communicate directly.@baiomys commented on GitHub (Dec 20, 2024):
Thanks for detailed response. Secret token in telegram serve as protection against guessing hook URL and tampering with it.
Entire hook, including this token, can be set at runtime.
https://api.telegram.org/botxxxxxxxxx:yyyyyyyyyyyyyyyyyyyyyyyyy/setWebhook?url=https://domain.tld/tghook/4af3a9903c03f97283e663e878746490&drop_pending_updates=True&max_connections=40&secret_token=49188f1beec02c87d653723975180445189f6a6a8bda509b5a8f75ac73f74e28
Which makes all calls perfectly secure.
Tampering with webhook in MAILPIT can't do any serious harm, so implementing such protection right away is not necessary.
On the other hand tampering with API calls can be a REAL DISASTER.
Pls consider in near future JWT or other protection apart from user:password.
=)
@axllent commented on GitHub (Dec 20, 2024):
Whilst I understand what damage can be caused by tampering with API calls, I still don't understand how a token is more secure than basic auth though? Both are transmitted as HTTP headers (client to server), and both a username and password can be as long & complex as you like.
@axllent commented on GitHub (Dec 20, 2024):
Sorry, I should say that JWT is more secure in that it is time based, however if someone is literally tampering with your HTTPS connection, then you have far bigger problems to worry about.