firebase_app_identity

Unofficial. Not affiliated with Google or Firebase.

A Firebase API key can be limited to an Android app (its package name and signing SHA-1) or to an Apple app (its bundle ID). The key then accepts only requests that name the app in the headers X-Android-Package, X-Android-Cert and X-Ios-Bundle-Identifier. The native Firebase SDKs read these values from the running app. This plugin does the same for firebase_app_dart:

  • Android: the package name and the SHA-1 of the certificate that signed the installed app.
  • iOS and macOS: the bundle ID.
  • Web, Linux and Windows: nothing; each call leaves things as they are.

The limit is not a security boundary: any program can send these headers.

// Options you build yourself:
final FirebaseOptions options = await AppIdentity.apply(
  const FirebaseOptions(apiKey: apiKey, appId: appId, projectId: projectId),
);

// A client that takes headers:
final FirebaseUserAuth auth = FirebaseUserAuth(
  apiKey: apiKey,
  apiKeyHeaders: await AppIdentity.apiKeyHeaders(),
);

// FlutterFire options, which have no Android values: at the start of main().
await AppIdentity.setAndroidApp();

Status: 0.1.0, on pub.dev.