我应该将 Expo 推送通知令牌视为敏感信息吗?如果是这样,我如何以安全的方式发送通知?

发布于 2025-01-14 12:50:21 字数 150 浏览 4 评论 0原文

在我的应用程序中,用户向某人发送消息后,会触发另一个函数来通知接收者。为此,发送者必须拥有接收者的推送令牌(前端)。我的问题是:那安全吗?有更好的方法吗?

我正在使用 Firebase,但我无法找到通过 Google Cloud Functions 发送此通知的方法...

In my app, after a user sends a message to someone, another function is triggered to notify the receiver. For that, the sender has to have the receiver's push token (front end). My question is: Is that safe? Is there a better approach?

I'm using Firebase but I couldn't figure out a way to send this notification through Google Cloud Functions...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

臻嫒无言 2025-01-21 12:50:21

是的,您可以将其视为敏感信息。令牌可能包含恶意用户访问时可用于冒充您的应用程序并向用户发送自己的消息的信息。虽然尚未报告实例,但遵循最佳安全实践是明智之举。

根据此文档使用 Expo 的推送 API 发送通知

我们提供将访问令牌与推送令牌一起使用作为额外的安全层。

如果您使用expo-server-sdk-节点,至少升级到v3.6.0,并将您的accessToken作为构造函数中的选项传递。否则,将标头 'Authorization': 'Bearer ${accessToken}' 与我们的推送 API 的任何请求一起传递。
启用推送安全性后,任何没有有效访问令牌发送的请求都将导致错误,代码为:UNAUTHORIZED

您可以查看此博客实施推送使用 Expo 和 Firebase Cloud Functions 进行通知,了解如何安全地推送通知。

Yes you can treat it as sensitive information. Tokens could contain information that when a malicious user accessed, it can be used to impersonate your app and send their own messages to users. While there's no reported instance (yet), it would be wise to follow the best security practices.

According to this documentation on Sending Notifications with Expo's Push API

We offer the use of an access token alongside the push token as an additional layer of security.

If you're using the expo-server-sdk-node, upgrade to at least v3.6.0 and pass your accessToken as an option in the constructor. Otherwise, pass in the header 'Authorization': 'Bearer ${accessToken}' with any requests to our push API.
Any requests sent without a valid access token after you enable push security will result in an error with code: UNAUTHORIZED.

You can check this blog on Implementing Push Notifications with Expo and Firebase Cloud Functions on how to push notifications securely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文