Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allUsers > Cloud Functions Invoker not added to HTTP functions in Node 10 runtime #646

Closed
timdiacon opened this issue Mar 28, 2020 · 9 comments

Comments

@timdiacon
Copy link

[REQUIRED] Version info

^3.0.2

node:
10

firebase-functions:
HTTP

firebase-tools:
7.4.0

[REQUIRED] Test case

Creating a new HTTP function from the cli by deploying code with firebase deploy --only functions creates a function which throws a 403 when called directly or CORS error when using firebase.functions().httpsCallable from the client

[REQUIRED] Steps to reproduce

As above

[REQUIRED] Expected behavior

The function should have 'allUsers > Cloud Functions Invoker' so it can be called from the client

[REQUIRED] Actual behavior

It doesn't have 'allUsers > Cloud Functions Invoker' and so throws a 403

Were you able to successfully deploy your functions?

Yes

@google-oss-bot
Copy link
Collaborator

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@RalphKemp
Copy link

Hello, I've had the same problem today, and thought I'd chime in with my temp fix (Including issues template for clarification).

Related issues

None.

[REQUIRED] Version info

node: 10.13.0

firebase-functions: 3.0.2

firebase-tools: 7.6.1

firebase-admin: 8.8.0

[REQUIRED] Steps to reproduce

  1. Create a normal http cloud function. ('test')
  2. run cli firebase deploy --only functions:test

[REQUIRED] Expected behavior

For a newly deployed cloud function to have allUsers in the permissions by default.

[REQUIRED] Actual behavior

Cloud function has no Cloud Functions Invoker, meaning all access is denied.

Were you able to successfully deploy your functions?

Yes.

Temp fix:

In the cloud console functions page, select a function to show the info panel. In the permissions tab, select ADD MEMBER. In the new members field, type allUsers. In the roles drop down, select cloud functions, then cloud functions invoker, and save.

It actually sort of makes sense for a function to have restricted permissions when it's first created, however I'm used to the default permissions being present, so it's a bug (or new feature) that definitely threw me off. Of course this doesn't fix the underlying problem, but hope it helps.

@mbleigh
Copy link
Contributor

mbleigh commented Mar 30, 2020

You need to upgrade the CLI to >= 7.7.0, which is when we added the automatic IAM policy adjustment for newly created functions. Note that this only applies to new functions, so upgrading and redeploying won't fix already deployed functions. To fix existing functions you can use gcloud:

gcloud functions add-iam-policy-binding $FUNCTION_NAME \
  --member='allUsers' \
  --role='roles/cloudfunctions.invoker'

@mbleigh mbleigh closed this as completed Mar 30, 2020
@RalphKemp
Copy link

@mbleigh Thanks for the info!

@alexpchin
Copy link

I'm still getting this issue:

firebase-functions: 3.6.2
firebase-tools: 8.4.1
firebase-admin: 8.12.1

I deleted my functions and then redeployed them and I am getting:

Screenshot 2020-05-30 at 03 53 42

@pedrocarloto
Copy link

Hello!
I am having the same problem when deploying from GitHub Actions. This only happens randomly and only when deploying new functions.
@alexpchin what is the URL for the interface you posted on your screenshot?
Thank you!

@taeold
Copy link
Contributor

taeold commented Sep 29, 2021

@pedrocarloto The screenshot is probably taken from https://console.cloud.google.com/functions - click on the function you are having issues with and look in the "Permissions" tab.

Firebase CLI tool makes a request to the Google Cloud Functions API to update the permissions post-deploy. Sometimes, this request may fail for various reasons (bad connection, not sufficient permission, etc). There should be a log entry when the request fails - can you share what you find there?

@pedrocarloto
Copy link

Hei @taeold!
Thank you for the reply.
I know that interface, but that only gives me the information for one function:
image

since I have about 80 functions I would like to know how many don't have the role.

I have tried the IAM interface, but it does not include the "Cloud Functions Invoker":
image

Regarding the logs, the deployment was done through GitHub Actions and I have looked there, but didn't find that request. I also searched on the function log itself on Google Cloud Log Explorer but also did not find that request. Where should I be looking?

Thank you!

@lsps9150414
Copy link

lsps9150414 commented Jan 24, 2024

For anyone running into this recently, I resolved it by:

  • updating all dependencies to the latest, for me it's
    • firebase-admin: ^12.0.0
    • firebase-functions: ^4.6.0
    • firebase-functions-test: ^3.1.1
    • firebase-tools: 13.0.3
  • delete all deployed functions (as the permission seems to be configured only when newly deployed)
  • redeploy all functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants