node.js - 对从 App Engine 到 Cloud Function 的请求进行身份验证
问题描述
关于这个主题有几个问题,但似乎大多数用例都围绕着 Firebase。
我在 App Engine 上运行了一个简单的 Node/Express 应用程序。我在那里安排了几个 cron 作业,它们在同一个项目中调用一些 Cloud Functions。我想将我的 Cloud Functions 配置为仅接受来自该 App Engine 服务的请求。
根据 Google 的 Cloud Function 文档,是不是就这么简单?
exports.myFunction = (req, res) => {
// Set CORS headers for preflight requests
res.set('Access-Control-Allow-Origin', 'https://my-app-engine-project.appspot.com');
res.set('Access-Control-Allow-Credentials', 'true');
if (req.method === 'OPTIONS') {
// Send response to OPTIONS requests
res.set('Access-Control-Allow-Methods', 'GET');
res.set('Access-Control-Allow-Headers', 'Authorization');
res.set('Access-Control-Max-Age', '3600');
res.status(204).send('');
} else {
// The rest of my cloud function logic goes here
}
};
我不清楚我需要从 App Engine 路由传递什么才能成功授权所有内容。
解决方案
推荐阅读
- html - 注册表单 - 浏览器将错误的字段作为用户名
- python - 【No module named 'cv2.cv2'】cannot import cv2 on AWS Lambda(Python3.7・OpenCV3)
- kubernetes - 通过 Terraform (for_each) 在 helm deploy 中使用不同的值
- javascript - Lottie Animation JSON 在没有任何解释的情况下使我的代码崩溃
- python - 使用属性名称列表声明 Python 类/接口
- r - 将字符元素传递给 render() 以创建几个不同的 PDF
- firebase - 无需电子邮件密码即可登录flutter
- azure - 通过 YAML 发布管道运行 azure powershell 脚本
- oracle - ORA-20000:ORU 10027:缓冲区溢出,限制为 20000 字节
- java - 我们可以使用 Itext 7 对齐嵌套/子列表而不使用缩进吗?有没有办法使用 Itext 7 List API 来实现这一点?