mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-09 08:26:00 +02:00
[GH-ISSUE #722] [Feature Request] Disable topic subscriptions through admin API #526
Labels
No labels
ai-generated
android-app
android-app
android-app
🪲 bug
build
build
dependencies
docs
enhancement
enhancement
🔥 HOT
in-progress 🏃
ios
prio:low
prio:low
pull-request
question
🔒 security
server
server
unified-push
web-app
website
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ntfy#526
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 @CreativeWarlock on GitHub (May 12, 2023).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/722
Hello mate,
For a small startup business that a friend and I have been creating and which would integrate your cool notication service, we got a little feature request for NTFY.sh that allows managing user subscriptions through a given admin user, preferrably via POST requests.
The following diagram shows a simplified model of our business, where users pay for accessing signal services that send data over different NTFY topics (represented by Channel A, B, C).
For the case that our customers cancel their subcriptions with one of our products, we need something like a flag that can be toggled on/off via admin user (or however you think it best to realize) to ensure that messages are no longer forwarded to a user's endpoint (phone).
This would be beneficial to keep the number of topics small (T=1 topic for N users) rather than setting up individual topics, resulting in T x N topics. It would also reduce the customer's time to setup the topics on the phone with ideally short topic names.
Would this be technically easy to realize? Let me know if you need additional information.
Kind regards
Marcel
@binwiederhier commented on GitHub (May 13, 2023):
This video shows a new endpoint
v1/accessthat lets you control the access control list via an API (admin user only!): https://docs.ntfy.sh/config/#access-controlIn the example, use
philis an admin, and is using the API to create an ACL entry for userphil1(which is not an admin). After the ACL entry is created,phil1can subscribe to topicgold. After the ACL entry is removed, the user's connection is killed as the access is revoked. Other connections (here: userphilis still subscribed) stay intact.Create ACL entry (similar to
ntfy accesscommand):Remove ACL entry:
Screencast_00067.webm
@binwiederhier commented on GitHub (May 13, 2023):
WIP PR: https://github.com/binwiederhier/ntfy/pull/727
@binwiederhier commented on GitHub (May 14, 2023):
I added the following endpoints that can be used as admin user:
GET v1/users- List users and user grants (ACL)PUT v1/users- Create a non-admin user and add to tierDELETE v1/users- Delete non-admin userPUT v1/users/access- Add/update ACL entry for a userDELETE v1/users/accessDelete ACL entry for a userHere's an example flow using the new endpoints (updated May 15)
1. Add user
2. Grant read only access
3. List users and user grants
4. Subscribe as "marcus"
5. Revoke access from "silver" (kills connection 2)
6. Delete user "marcus" (kills connection 1)
@binwiederhier commented on GitHub (May 14, 2023):
Sounds good?
@CreativeWarlock commented on GitHub (May 14, 2023):
Going to test your fast solution after my vacations; I'll be back on Sunday evening, so probably Monday-Tuesday I can test it :)
@binwiederhier commented on GitHub (May 15, 2023):
Updated the endpoints and examples again. I think I'm happy with this and will merge it as-is. Given that it won't be released, we can still change it if you like @CreativeWarlock. Enjoy your time off.
@binwiederhier commented on GitHub (May 18, 2023):
This is now part of v2.5.0. I'll leave the ticket pending confirmation that this is ok.
@CreativeWarlock commented on GitHub (May 24, 2023):
The solution seems to fulfill our needs perfectly! I'll update NTFY on my server and need to implement these ACL commands in our backend services. From the looks of your example, I would expect it will work right away. Will report back soon.
So excited! 😄
@CreativeWarlock commented on GitHub (May 24, 2023):
Small typo found in "1. Add User:"
curl -X PUT -u admin:adminpass -d '{"username":"marcus","password":"marcuspass","tier":"business"}' localhost:2586/v1/users
Response:
('topic' was probably meant, but it's not being used in user creation which is fine as it is 👍 )
All other "CRUD" operations work fine.
@CreativeWarlock commented on GitHub (May 24, 2023):
I guess in the app on the smartphone, our customers have to add their user name somewhere so that messages can be received on the topics they are subscribed / paying for.
However, if I go to
'settings' -> 'general' -> 'manage users'
and add a new user (I previously created 'hans' and gave it RO permission to some topics), I cannot "create" that new user:
Any ideas what I might've done wrong?
@binwiederhier commented on GitHub (May 24, 2023):
This seems correct to me. You are creating a user in this API call, and are assigning the tier
businessto them. If that tier does not exist, the endpoint will error out. Thattierparameter is optional.User creation does not relate to topics at all. The flow is: (a) you first create a user using
v1/users, and then you (b) grant access to a topic usingv1/users/access.The user management in the Android app is subpar. I will work on that in the near future. For now, you can add an existing (!) user like you said, but you cannot create a user in the Android app. That is correct. I may add that feature later, but it won't help your use case, IMHO.
@CreativeWarlock commented on GitHub (May 24, 2023):
Thanks for the link to tiers. I have obviously overlooked that feature in your docs.
Yes sadly, if users can't connect to nfty topics through the credentials they get from our system, i.e. after they register & subscribe to our product(s), the business case is not functional and we cannot move on.
Let me know if you need additional infos.
@CreativeWarlock commented on GitHub (May 24, 2023):
Wait a sec.. it IS possible to connect with an existing user to the server?
That would be perfectly enough then. Question is: How?
That "Benutzer hinzufügen" (Add user) seems to be no link, so idk how to configure the app to use an existing user (that gets created & configured from my backend service).
I'm most likely missing something - so any hint would be much appreciated! :)
@binwiederhier commented on GitHub (May 25, 2023):
My apologies for the confusion regarding this "user add" feature.
You are in the correct screen. To add an existing user in the Android app, you have to go to Settings -> Manage users -> Add new user" (Neuen Benutzer hinzufügen). And then add the user for whatever your server is.
The likely reason it didn't work for you above is that you have to prefix the server with "http://" or "https://" in the "Server URL field, e.g. "https://ntfy.example.com" is correct, but "ntfy.example.com" will not work. As I said, the UX is quite annoying. 😬
@CreativeWarlock commented on GitHub (May 25, 2023):
Ah yes, sorry that I didn't try adding the protocol myself.
(Btw. I wrote you on Discord because messages don't come through. It's maybe my server settings or something else is missing between NTFY server and the NTFY app.)
@CreativeWarlock commented on GitHub (May 27, 2023):
Ok, your feature seems to work fine: I just sent a message to a topic, the NTFY server returned a success response and the message arrives in the app. However, with a delay of 30 minutes.