【发布时间】:2022-11-21 11:23:11
【问题描述】:
我阻止未经身份验证的用户使用我的 Firebase Cloud Functions 的方法是在所有函数的开头添加此样板代码。请注意,我正在使用 Callable Function functions.https.onCall,不是HTTP函数functions.https.onRequest
if (!context.auth) {
// Throwing an HttpsError so that the client gets the error details.
throw new functions.https.HttpsError(
"failed-precondition",
"The function must be called while authenticated."
);
}
有没有更好的方法来阻止未经身份验证的用户,以便无效调用甚至不能调用我的函数?
【问题讨论】:
标签: firebase google-cloud-functions