[Functions, Storage] Emulator authentication fix - #16541
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
|
See the discussion at #16536. I'm not sure about this. For apps testing other Firebase products, it might be better to let Auth silently succeed than to throw an exception. |
|
@ncooke3 See the new |
Enforce explicit errors for insecure HTTP token withholding and refactor authorization logic
Description
This pull request improves the developer experience and safety of the transport layer security rules introduced for Firebase Functions and Firebase Storage. It addresses an issue where silently stripping credentials over non-loopback HTTP connections could result in confusing application behavior (such as unexpected guest onboarding) by instead failing fast with an explicit error.
Key Changes
unauthenticatederror (instead of silently sending an unauthenticated request). Unauthenticated requests (where no tokens are present) remain unaffected and will still proceed normally.Functions.swiftandStorageTokenAuthorizer.swiftby using early-returnguardstatements, significantly improving code readability.StorageTokenAuthorizer.swiftinto a local variable to prevent redundant.lowercased()string operations.Testing
testCallFunctionOverHttpWithoutLocalhostFailsWhenTokensPresentandtestInsecureHostFailsWhenTokensPresentto verify that requests are explicitly blocked withunauthenticatederrors when tokens are withheld.testCallFunctionOverHttpWithoutLocalhostSucceedsWhenNoTokensPresentandtestInsecureHostSucceedsWhenNoTokensPresentto ensure that standard, unauthenticated HTTP requests continue to work as expected.GTMSessionFetcherinstances withallowedInsecureSchemes = ["http"]during unit tests to accurately simulate the emulator networking conditions.Related Issues