Skip to content

feat(firebase_app_check,windows): add custom App Check provider support#18184

Open
lukemmtt wants to merge 3 commits intofirebase:mainfrom
lukemmtt:feat/windows-custom-app-check-provider
Open

feat(firebase_app_check,windows): add custom App Check provider support#18184
lukemmtt wants to merge 3 commits intofirebase:mainfrom
lukemmtt:feat/windows-custom-app-check-provider

Conversation

@lukemmtt
Copy link
Copy Markdown
Contributor

@lukemmtt lukemmtt commented Apr 12, 2026

Summary

Adds custom App Check provider support for Windows, addressing the custom-provider part of issue 12227. Combined with the debug provider from PR 18140, this allows Flutter Windows apps to meet Firebase App Check enforcement for Firestore, Functions, Storage, Auth, and Realtime Database.

Specifically, this PR adds the FlutterFire plumbing (Pigeon bridge and Windows plugin wiring) that exposes the Firebase C++ SDK's custom-provider interface to Flutter developers. With this infrastructure, Flutter apps on Windows can supply App Check tokens by implementing a custom Dart handler. That handler is the integration point any Windows attestation (TPM hardware attestation, Microsoft Store licensing, Azure Attestation, or an auth-backed token minted by a Cloud Function) needs to feed App Check.

Usage

Activate the provider alongside existing platform providers and register your handler to supply fresh tokens:

await FirebaseAppCheck.instance.activate(
  providerWindows: const WindowsCustomProvider(),
);

FirebaseAppCheckFlutterApi.setUp(MyWindowsHandler());

class MyWindowsHandler implements FirebaseAppCheckFlutterApi {
  @override
  Future<CustomAppCheckToken> getCustomToken() async {
    final result = await myBackend.mintAppCheckToken();
    return CustomAppCheckToken(
      token: result.token,
      expireTimeMillis: result.expireTimeMillis,
    );
  }
}

The Firebase SDK will automatically attach tokens from this handler to subsequent Firebase backend requests.

Design notes

The public Flutter API follows existing naming conventions (providerWindows), aligning with providerAndroid and providerApple. The shared Pigeon activate API includes a corresponding optional windowsProvider parameter.

CustomAppCheckToken includes both the token string and its absolute expiry in Unix epoch milliseconds. Returning the expiry from Dart lets consumer backends pick arbitrary TTLs (short for stricter posture, longer for fewer round trips) without the plugin hardcoding a refresh window.

Currently, GetLimitedUseAppCheckToken delegates to GetAppCheckToken(false) because the Firebase C++ SDK does not yet offer a dedicated limited-use token method. Regular App Check enforcement is unaffected; only replay-protection scenarios see this fallback behavior. This path can transition once the SDK supports limited-use tokens.

References

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. 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.

@lukemmtt lukemmtt force-pushed the feat/windows-custom-app-check-provider branch from 98e57f2 to 976a491 Compare April 12, 2026 22:47
… provider, clarify provider docs

The Dart FlutterApi now returns CustomAppCheckToken, a class carrying both the minted token and its wall-clock expiry in Unix epoch milliseconds, instead of just a string. This lets backends mint tokens with arbitrary lifetimes without the plugin hardcoding a refresh window, and it removes a 55-minute constant from the C++ plugin that assumed every backend mints ~1-hour tokens. Short-lived tokens for stricter posture and longer-lived tokens for fewer round-trips are both supported by the same API.

The Windows plugin's GetToken now pipes the expiry from Dart straight through to AppCheckToken.expire_time_millis, so the Firebase C++ SDK caches for the exact lifetime the backend chose.

Also updates stale provider docs on windows_providers.dart (the base and debug-provider docs previously described debug as the only supported Windows provider, which was already out of date once custom support landed) and expands WindowsCustomProvider's docs with a usage example showing a FirebaseAppCheckFlutterApi implementation.

Regenerates all Pigeon bindings (Dart, Kotlin, Swift, C++) from the updated source.
@lukemmtt lukemmtt force-pushed the feat/windows-custom-app-check-provider branch from 0964913 to b7f0ba2 Compare April 13, 2026 03:12
@SelaseKay
Copy link
Copy Markdown
Contributor

Hey @lukemmtt, thanks for the contribution. Could you please add tests to cover this change?

@lukemmtt
Copy link
Copy Markdown
Contributor Author

Will do, thanks for the reminder @SelaseKay 🙏🏻

Exercises the Windows activate() payload for WindowsCustomProvider and WindowsDebugProvider (with and without an explicit debug token), plus the FirebaseAppCheckFlutterApi success and PlatformException envelopes.
@lukemmtt lukemmtt marked this pull request as ready for review April 14, 2026 16:52
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.

2 participants