-
-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create token with restricted permissions #5349
Comments
Lemmy currently has no push notif support, and we're going to use ntfy / unified push for that. |
I am aware of this. At the moment, Lemmy clients that support push notifications use their own servers - not the Lemmy backend - to send those push notifications. Currently, each one of those servers contains a database of the users' tokens. This isn't ideal.
Cool 👍 Lemmy supporting push notifications directly in future would be great for Android clients. Unfortunately, I don't think this implementation will eliminate the need for a central server for iOS users. This is because iOS requires that all notifications be forwarded through one of Apple's servers, and an authentication token specific to the app needs to be attached to each request. If the Lemmy backend were to send notifications to an iOS client, it would need to:
Implementing this seems infeasible. The end result is that I'd probably still need a central server, and I'd probably still need to store all of the user tokens on it. So I don't think the Lemmy backend using ntfy would solve my issue. |
Makes sense. How do you think this could be implemented? I suppose a parameter |
A |
Have you looked at how the Mastodon iOS apps do it? Something like https://github.com/mastodon/webpush-apn-relay. Yes it is centralized but it is just a dumb relay that doesn't require storing user tokens.
Looking at how Mastodon apps do it, I don't think that's true. |
This could probably be part of #1368 (scoped permissions). |
As I understand it, there are currently two ways of authenticating push notifications. If you want the server to be able to send notifications to multiple different iOS apps, you need to attach an authentication token to each request. If the Lemmy server was sending notifications directly, it would need to send them to more than one iOS app and so would need to attach this token. If you are only sending to a single iOS app this isn't necessary - you can instead create a certificate and upload it to Apple through the developer portal. When you do this, you need to tie the certificate to a specific bundle ID. Then, APNS understands that any requests coming from your server are for your specific app. I don't think this authentication method would work for the Lemmy backend because you can only send notifications to one iOS app.
I hadn't seen that repository before, thanks! That's super useful. I'd certainly look into doing it that way if Lemmy implements ntfy. |
I just tested it with Mastodon, logged into two separate apps (Mastodon iOS app and Ice Cubes iOS app, on same device) with a single Mastodon account, and all push notifications came thru just fine for each app :) Both Ice Cubes and Mastodon use Web Push behind the scenes, with a relay (as linked to before). More info here: https://docs.joinmastodon.org/methods/push/ (It's worth noting that documentation is a bit outdated since Mastodon 4.4 will allow Android apps to directly push to FCM w/ decryption, pretty cool! LucasGGamerM/moshidon#588 also mastodon/mastodon#33528 and https://unifiedpush.org/news/20250131_push_for_decentralized/)
It seems like the safest way. Lemmy would implement the standardized WebPush (RFC8030+RFC8291+RFC8292) which lemmy iOS apps would then use with their own relay to push to APN. To be clear though, Ntfy is just the notification service for FOSS android push notifications. iOS and Google Play Android would not (well really, can't) use it. Here's an example of what would happen when Lemmy generates a new push noti, for each platform:
There's some nice diagrams here: https://unifiedpush.org/ |
Thanks so much, that's super useful! :) |
Requirements
Is your proposal related to a problem?
In order for a mobile client to support push notifications, those notifications need to be sent from an external server. To do this, the server needs to store the user's token so that it can check for any new messages.
Despite only needing to read the user's inbox, the server will be able to perform any operation on behalf of the user (including deleting posts, comments, communities etc), aside from deleting the account itself. This isn't ideal - if there was a data breach, a lot of damage could be done.
Describe the solution you'd like.
Add an API endpoint that creates a read-only token. The Lemmy backend would return an error for any non-
GET
requests made using this token. When the user enables push notifications, the client could create a read-only token and send it to the server.Describe alternatives you've considered.
Additional context
No response
The text was updated successfully, but these errors were encountered: