Skip to content

App Check (Desktop): register function registry calls on every App - #1985

Open
AustinBenoit wants to merge 4 commits into
mainfrom
fix/app-check-register-per-app
Open

AustinBenoit wants to merge 4 commits into
mainfrom
fix/app-check-register-per-app

Conversation

@AustinBenoit

Copy link
Copy Markdown
Contributor

Description

On desktop, App Check registered its function registry entries only for the first App created, using a process-wide counter. Each App has its own registry, so Auth, Database, Firestore, Functions and Storage on any other App found 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:

  • the four registry functions exist on both;
  • each App gets its own token through its registry.

Both fail without the fix. Built and run on Linux (GCC, Firestore excluded).


Type of Change

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Fixes #1970

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AustinBenoit
AustinBenoit marked this pull request as ready for review November 25, 2026 03:41
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] App Check on desktop registers its token functions on the first App only, so a second App's requests carry no token

1 participant