Repository navigation
App Check (Desktop): register function registry calls on every App - #1985
Conversation
AppCheckInternal used a process-wide counter to register its function registry entries only when the first instance was created and to unregister them only when the last one was destroyed. Each App has its own function registry, so a second App never got the entries: Auth, Database, Firestore, Functions and Storage on that App looked up FnAppCheckGetTokenAsync, found nothing, and sent their requests without an App Check token. Teardown had the mirror-image problem and unregistered from whichever App happened to bring the counter to zero. The registered callbacks already find the AppCheck instance from the App they are given, so drop the counter and register and unregister on each instance's own App. Fixes #1970
There was a problem hiding this comment.
Code Review
This pull request updates the desktop App Check implementation to register its functions on every App instance's registry rather than using a global count, fixing an issue where secondary App instances failed to send App Check tokens. It also adds a new desktop test suite to verify this behavior. The feedback recommends adding defensive null checks for app_ in both InitRegistryCalls and CleanupRegistryCalls to prevent potential null pointer dereferences. Additionally, it points out an existing bug in FunctionRegistry::UnregisterFunction where a range-erase with identical iterators results in a silent no-op.
… against null app_
…r-per-app # Conflicts: # release_build_files/readme.md
…registration - Resolve release_build_files/readme.md conflict against origin/main. - Add DestroyingAppCheckUnregistersOnlyItsAppsRegistryFunctions verifying that destroying one AppCheck unregisters all 4 FnAppCheck* entries only on its own App without recreating AppCheck, leaves other Apps intact, and re-registers cleanly when recreated.
❌ Integration test FAILEDRequested by @AustinBenoit on commit dc5dbb2
Add flaky tests to go/fpl-cpp-flake-tracker |
Description
On desktop, App Check registered its function registry entries only for the first
Appcreated, using a process-wide counter. EachApphas its own registry, so Auth, Database, Firestore, Functions and Storage on any otherAppfound nothing and sent requests without an App Check token.This removes the counter and registers and unregisters on each instance's own
App.Testing
New
app_check/tests/desktop/app_check_desktop_test.cc, with two Apps:Both fail without the fix. Built and run on Linux (GCC, Firestore excluded).
Type of Change
Fixes #1970