简体   繁体   English

Firebase Cloud Functions Http请求-验证用户

[英]Firebase Cloud Functions Http Request - VALIDATE USER

I'm building a web app where I want to call a cloud function from the client to edit a part of the database that shouldn't be accessible to the user. 我正在构建一个Web应用程序,我想从客户端调用云功能来编辑用户不应该访问的数据库部分。

The user should only be able to edit the hidden part of the database that is theirs. 用户应该只能编辑属于他们的数据库的隐藏部分。

I want to use an HTTP request trigger (as it seems the most practical), but I need to be able to have the client somehow prove through either a parameter or some other method that they are a certain user. 我想使用HTTP请求触发器(似乎是最实际的触发器),但是我需要能够让客户端以某种方式通过参数或其他方法证明他们是特定用户。

Is this possible, if so what is the best way to do this? 如果可能的话,这样做的最佳方法是什么?

callable functions . 可调用函数 Note that firebase.auth() provides user/client authentication. 请注意,firebase.auth()提供了用户/客户端身份验证。 So, the Firebase Functions will be talking to the data store via a service account. 因此,Firebase功能将通过服务帐户与数据存储进行对话。

Callable functions are similar to other HTTP functions, with these additional features: 可调用函数类似于其他HTTP函数,但具有以下附加功能:

  • With callables, Firebase Authentication and FCM tokens, when available, are automatically included in requests. 对于可调用对象,Firebase身份验证和FCM令牌(如果可用)会自动包含在请求中。
  • The functions.https.onCall trigger automatically deserializes the request body and validates auth tokens. 函数.https.onCall触发器会自动反序列化请求正文并验证auth令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM