Feature Request: Add authentication to ntfy hook #621

Closed
opened 2022-12-19 20:19:03 +00:00 by crazy-weasel · 6 comments

What I'm trying to do and why

I run a self hosted ntfy server with authentication enabled and no anonymous access as it's private instance.

Other notes / implementation ideas

The ntfy server supports authentication via basic authorization (Authorization-Header) or as a query parameter. (docs)

The configuration could be extend to support the authentication data and if present, the data could be added to the headers in line 52 of borgmatic/hooks/ntfy.py#L52

Environment

borgmatic version: 1.7.5

borgmatic installation method: pip

Borg version: 1.2.0

Python version: 3.10.6

Database version (if applicable): n/a

operating system and version: Ubuntu 22.04.1 LTS

#### What I'm trying to do and why I run a self hosted ntfy server with authentication enabled and no anonymous access as it's private instance. #### Other notes / implementation ideas The ntfy server supports authentication via basic authorization (Authorization-Header) or as a query parameter. ([docs](https://docs.ntfy.sh/publish/#authentication)) The configuration could be extend to support the authentication data and if present, the data could be added to the headers in line 52 of [borgmatic/hooks/ntfy.py#L52](https://projects.torsion.org/borgmatic-collective/borgmatic/src/branch/master/borgmatic/hooks/ntfy.py#L52) #### Environment **borgmatic version:** 1.7.5 **borgmatic installation method:** pip **Borg version:** 1.2.0 **Python version:** 3.10.6 **Database version (if applicable):** n/a **operating system and version:** Ubuntu 22.04.1 LTS
Owner

Makes sense. Thanks for filing this! Sounds like borgmatic's ntfy configuration should also be changed as part of this implementation to allow configuration of a ntfy username and password. And then Python's requests library could maybe handle the encoding:

requests.post(..., auth=requests.auth.HTTPBasicAuth(username, password))
Makes sense. Thanks for filing this! Sounds like borgmatic's ntfy configuration should also be changed as part of this implementation to allow configuration of a ntfy `username` and `password`. And then Python's `requests` library could maybe handle the encoding: ```python requests.post(..., auth=requests.auth.HTTPBasicAuth(username, password)) ```
witten added the
good first issue
label 2023-02-04 17:14:56 +00:00
Owner

This will be part of the next release (1.7.8).

This will be part of the next release (1.7.8).
Owner

Just released. Thanks again!

Just released. Thanks again!
Author

Great! I just updated my config, and it works as expected.

Thanks to all involved. :)

Great! I just updated my config, and it works as expected. Thanks to all involved. :)

Hmmz, just fyi in case someone else stumbles upon this, i noticed that in my upgraded version (i used borgmatic config generate -s .. -d ...) this part of the config was missing...:

# The username used for authentication.
    # username: testuser
Hmmz, just fyi in case someone else stumbles upon this, i noticed that in my upgraded version (i used `borgmatic config generate -s .. -d ...`) this part of the config was missing...: ``` # The username used for authentication. # username: testuser ```
Owner

Thanks for the comment. Would you mind filing a ticket with details about this issue? It sounds like it could be a bug.

Thanks for the comment. Would you mind filing a ticket with details about this issue? It sounds like it could be a bug.
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#621
No description provided.