RealComposer

Firebase Safe & Unsafe Practices

Direct Answer

The Firebase web config (including apiKey) is a public identifier, not a secret. Data is protected by Firestore, Realtime Database, and Storage Security Rules plus App Check. Admin SDK service account JSON bypasses rules and must only exist on servers.

Credentials & Where They Belong

Client safe
Web config apiKey

Identifies your project. Restrict it to required APIs in Google Cloud Console.

Server only
Service account JSON (Admin SDK)

Full admin access that ignores Security Rules.

Server only
FCM server credentials

Send push notifications to any device in your project.

Safe Practices

  • Write least-privilege Security Rules

    Require request.auth and match document ownership in rules for Firestore, Realtime Database, and Storage.

  • Enable App Check

    App Check makes it harder for scripts outside your app to call your Firebase backends.

  • Verify ID tokens on your server

    Use verifyIdToken in trusted code before acting on a user identity sent from the client.

Unsafe Practices

  • Shipping test-mode rules to production

    Rules like allow read, write: if true expose your entire database to anyone with the config.

  • Bundling the service account JSON into an app

    It grants admin access that bypasses every rule you wrote.

  • Relying on hiding the config as security

    The config is visible in every client. Only rules and App Check protect data.

The RealComposer Pattern

Put service account credentials in the vault and expose aggregated or admin reads as edge pipelines. Clients keep using the Firebase SDK under Security Rules for user-owned data.

START BUILDING FREE

Frequently Asked Questions

Q:Is the Firebase apiKey a secret?

No. It identifies the project and is safe to ship. Security Rules and App Check are what prevent abuse.

Related Concepts