让React Native应用直接发布到Google Pub/Sub主题是一种好习惯吗? [英] Is it good practice to have a React Native app Publish directly to a Google Pub/Sub topic?

查看:55
本文介绍了让React Native应用直接发布到Google Pub/Sub主题是一种好习惯吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在构建一个无服务器平台,该平台包含使用React Native构建的Android和iOS应用,并在后端使用Google Cloud Functions和Firebase.鉴于某些操作由多个Cloud Functions处理,我们认为将应用程序发布到发布/订阅主题,然后在应用程序发布时让不同的Cloud Functions触发订阅"事件是一个好主意.让React Native应用直接发布到Google Pub/Sub主题是一种好习惯,还是我们应该具有HTTPS Cloud Function来进行主题发布?

We are building a serverless platform consisting of Android and iOS apps build using React Native and on the backend we use Google Cloud Functions and Firebase. Given that some actions are handled by multiple Cloud Functions, we thought it would be a good idea to have the apps Publish to a Pub/Sub topic and then have the different Cloud Functions fire Subscribe events when the apps publish. Is it good practice to have a React Native app Publish directly to a Google Pub/Sub topic or should we have an HTTPS Cloud Function do the topic publishing?

如果应用程序执行发布/订阅是一种好习惯,那么有关如何处理凭据的任何提示?有一个Node.js客户端,但没有一个React Native客户端.主要问题似乎与您应该设置的环境变量有关(例如,导出GOOGLE_APPLICATION_CREDENTIALS ="/home/user/Downloads/[FILE_NAME] .json").

If it is good practice for the apps to do the Pub/Sub, any tips on how to handle the credentials? There is a Node.js client but not a React Native one in particular. The main issue seems to be with the environmental variable you are supposed to set (e.g. export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/[FILE_NAME].json").

谢谢!

推荐答案

如果您要通过客户端设备与Firebase(或任何服务器)进行通信,则最佳做法是使用客户端身份验证,而不是某些所有人的安全令牌.

If you are going to communicate with firebase (or any server) from the client´s device, best practice is so that you use clients authentication, and not some secure token for all.

firebase附带了客户端身份验证,这是有好处的.

There is the benefit, that firebase comes with client authentication.

我会研究两种方法.

  1. 直接将firebase用作队列.实际上,它能够做到这一点,并且具有Firebase身份验证功能.(请参见 https://github.com/firebase/firebase-queue )
  2. 使用Firebase云功能.好处是,如果您使用Firebase身份验证登录用户,则会自动包括身份验证.从那里,您可以编写一个简单的云功能以将数据添加到队列中.(请参见 https://firebase.google.com/docs/functions/callable )

这篇关于让React Native应用直接发布到Google Pub/Sub主题是一种好习惯吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆