【发布时间】:2019-10-13 03:43:38
【问题描述】:
我正在尝试在我的 Google Cloud 功能中使用 Google 的 Identity Platform。我没有找到任何有关它的信息。我想我应该能够做这样的事情:
exports.helloWorld = (req, res) => {
var user = getAuthenticatedUser(); //I made up this function and I'm imagining there's some API from google to do this.
if ( user === undefined ) {
res.status(403).send('Forbidden!');
}
let message = req.query.message || req.body.message || 'Hello ' + user;
res.status(200).send(message);
};
有人可以指导我找到正确的文档吗?我觉得我在兜圈子,无法确定如何或应该这样做。
谢谢
【问题讨论】:
-
您使用私有云功能吗?并且您不想仅授权经过身份验证的用户访问它,未在您的项目中注册的用户,任何外部用户。我说的对吗?
-
我的目标是让用户使用 Google 的身份平台登录(这允许使用电子邮件/密码注册或使用社交登录,如 facebook、google、linkedIn 等)。只有通过该平台(在我的项目中有配置)进行身份验证的用户才能调用我的函数。我希望这可以澄清它。谢谢
-
简短回答:你不能。但我正在写一篇关于 Cloud Endpoint 以及如何使用 API Key 保护访问的文章。但 Firebase Auth 也有一个条件。你可以自己试试。我标记了这个问题,我会在我的文章发布时更新回复,并且我会用 firebase auth 为你做一个特例(它和 CIP 完全一样)
标签: google-cloud-platform google-cloud-functions google-identity