Skip to content

Commit

Permalink
Ensure callable functions have invoker correctly set to "public" (#4335)
Browse files Browse the repository at this point in the history
Implemented fix for issue introduced in `v10.3.0` where callable functions were not having their `invoker` property correctly set to `"public"` that would in turn cause access issues with the deployed functions (as detailed in #4327).

Will also fix issues such as #3965, that are presumably cause by version mismatches/upgrades introducing this issue.

Fixes issue by adding specific handling for callable functions and always setting the `invoker` to `"public"`.

Also fixed issue with `taskQueueTrigger` endpoints calling wrong method/passing wrong args when trying to set invoker.
  • Loading branch information
chrisbrown-io authored and tohhsinpei committed Mar 23, 2022
1 parent 7bb354b commit d933393
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 80 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Upgrade Storage Rules Runtime to v1.0.2.
- Adds support for an environment variable `FIREBASE_HOSTING_UPLOAD_CONCURRENCY` to specify custom levels of Hosting upload concurrency (defaults to 200).
- Fixes error handling in `auth:export` when API calls would fail.
- Fixes bug where new callable functions were not publicly accessible. (#4327)
14 changes: 13 additions & 1 deletion src/deploy/functions/release/fabricator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ export class Fabricator {
})
.catch(rethrowAs(endpoint, "set invoker"));
}
} else if (backend.isCallableTriggered(endpoint)) {
// Callable functions should always be public
await this.executor
.run(async () => {
await gcf.setInvokerCreate(endpoint.project, backend.functionName(endpoint), ["public"]);
})
.catch(rethrowAs(endpoint, "set invoker"));
} else if (backend.isTaskQueueTriggered(endpoint)) {
// Like HTTPS triggers, taskQueueTriggers have an invoker, but unlike HTTPS they don't default
// public.
Expand Down Expand Up @@ -297,14 +304,19 @@ export class Fabricator {
.run(() => run.setInvokerCreate(endpoint.project, serviceName, invoker))
.catch(rethrowAs(endpoint, "set invoker"));
}
} else if (backend.isCallableTriggered(endpoint)) {
// Callable functions should always be public
await this.executor
.run(() => run.setInvokerCreate(endpoint.project, serviceName, ["public"]))
.catch(rethrowAs(endpoint, "set invoker"));
} else if (backend.isTaskQueueTriggered(endpoint)) {
// Like HTTPS triggers, taskQueueTriggers have an invoker, but unlike HTTPS they don't default
// public.
const invoker = endpoint.taskQueueTrigger.invoker;
if (invoker && !invoker.includes("private")) {
await this.executor
.run(async () => {
await gcf.setInvokerCreate(endpoint.project, backend.functionName(endpoint), invoker);
await run.setInvokerCreate(endpoint.project, serviceName, invoker);
})
.catch(rethrowAs(endpoint, "set invoker"));
}
Expand Down

0 comments on commit d933393

Please sign in to comment.