From 7e1a71b6949b292a9d9c341281f359a2f969c2b7 Mon Sep 17 00:00:00 2001 From: lrabane Date: Thu, 17 Feb 2022 20:26:04 +0100 Subject: [PATCH] Add docs for auth support with CLI --- docs/subscribe/cli.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/subscribe/cli.md b/docs/subscribe/cli.md index 2d3f83b4..52e005c0 100644 --- a/docs/subscribe/cli.md +++ b/docs/subscribe/cli.md @@ -196,3 +196,27 @@ EOF sudo systemctl daemon-reload sudo systemctl restart ntfy-client ``` + + +### Authentication +Depending on whether the server is configured to support [access control](../config.md#access-control), some topics +may be read/write protected so that only users with the correct credentials can subscribe or publish to them. +To publish/subscribe to protected topics, you can use [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication) +with a valid username/password. For your self-hosted server, **be sure to use HTTPS to avoid eavesdropping** and exposing +your password. + +You can either add your username and password to the configuration file: +=== "~/.config/ntfy/client.yml" + ```yaml + - topic: secret + command: 'notify-send "$m"' + user: phill + password: mypass + ``` + +Or with the `ntfy subscibe` command: +``` +ntfy subscribe \ + -u phil:mypass \ + ntfy.example.com/mysecrets +```