隐藏 Cloud Endpoints 背后的 Cloud Functions 执行

Hide Cloud Functions execution behind Cloud Endpoints

我想知道是否可以 restrict/hide 使用云端点直接访问我的云功能。

我遵循了 Google 的 this 教程。

在 link 上说:

With this set up, ESP intercepts all requests to your functions and performs any necessary checks (such as authentication) before invoking the function

我设法完成了本教程,在端点上添加了 JWT 身份验证机制。但是即使我可以从 CloudRun/ESP 访问 URL (启用保护),我仍然可以从函数的直接 URL 访问(保护不适用于此水平,所以它不安全)。我怎样才能避免这种情况?

提前致谢!

这里是 GCF PM,

您需要启用 GCF IAM,如第 5 步后半部分所述,"grant ESP the Cloud Identity and Access Management (Cloud IAM) permission to invoke your functions."

这需要 "Before you begin" 的第 7 步,即 joining the Alpha whitelist

之后,您可以按照上述方法保护功能:

gcloud alpha functions add-iam-policy-binding FUNCTION_NAME \
    --member "serviceAccount:ESP_PROJECT_NUMBER-compute@developer.gserviceaccount.com" \
    --role "roles/cloudfunctions.invoker" \
    --project FUNCTIONS_PROJECT_ID

对 alpha 阶段产品奇怪的重叠表示歉意--GCF IAM 应该 public 很快!