// auth and identity
Via APIFirebase Authentication email verification with pingutil
Firebase Authentication creates an account for any address that passes the client SDK, and the free-tier abuse shows up later in Firestore and billing. A beforeUserCreated blocking function runs before the user is written; calling pingutil in fast mode from it rejects disposable and machine-generated addresses with an HttpsError inside Firebase's 7-second window.
Where it connects: Firebase Authentication blocking functions, beforeUserCreated
What goes wrong without it
- Scripts create hundreds of email-password accounts in our Firebase project to grab free usage.
- We only find the fake accounts when Firestore reads spike or the bill arrives.
- Email link sign-in means anyone with a temp inbox can create an account in two clicks.
What you can do with Firebase Authentication and pingutil
Reject disposable addresses before creation
Throw HttpsError when verdict.is_spam is true. The account is never created, so there is nothing to delete later.
Stop scripted registrations
email_signals.is_randomized catches the random local parts bots generate, including on domains that are not on any disposable list.
Mark low-trust users with custom claims
Blocking functions can return customClaims. Set a low_trust claim for role or system addresses and enforce it in your Security Rules.
Set it up
- 1
Upgrade the project to Firebase Authentication with Identity Platform, which blocking functions require.
- 2
Store the pingutil key with firebase functions:secrets:set PINGUTIL_KEY.
- 3
Add the function below to your Cloud Functions codebase and deploy it with firebase deploy --only functions.
- 4
In the Firebase console, check under Authentication > Settings > Blocking functions that it is registered for the before account creation event.
- 5
Create an account with a disposable address from your app and confirm it is rejected.
import { beforeUserCreated, HttpsError } from 'firebase-functions/v2/identity';
import { defineSecret } from 'firebase-functions/params';
const PINGUTIL_KEY = defineSecret('PINGUTIL_KEY');
export const screensignup = beforeUserCreated({ secrets: [PINGUTIL_KEY] }, async (event) => {
const email = event.data?.email;
if (!email) return; // phone or anonymous sign-up
let data;
try {
const res = await fetch('https://pingutil.com/v1/lookup', {
method: 'POST',
headers: {
authorization: 'Bearer ' + PINGUTIL_KEY.value(),
'content-type': 'application/json',
},
body: JSON.stringify({ input: email, skip_enrichment: true }),
signal: AbortSignal.timeout(3000), // Firebase allows 7 s in total
});
if (!res.ok) return; // fail open
data = await res.json();
} catch {
return;
}
if (data.verdict.is_spam) {
throw new HttpsError('invalid-argument', 'Please sign up with a permanent email address.');
}
if (data.verdict.low_trust) {
return { customClaims: { low_trust: true } };
}
});What to do with each result
| pingutil result | Action in Firebase Authentication |
|---|---|
| verdict.is_spam: true | throw HttpsError("invalid-argument"); no account is created |
| verdict.low_trust: true | Return customClaims { low_trust: true } and check it in Security Rules |
| category: "company" | Allow; run a full lookup later if you want company data |
| Timeout, 429 or 5xx | Return without throwing (fail open) |
Limits to plan for
- Firebase requires a blocking function to respond within 7 seconds, or the sign-up fails. That is why the snippet uses fast mode with a 3-second timeout instead of a full mailbox check.
- Blocking functions need Firebase Authentication with Identity Platform. Firebase wraps thrown errors, so your client must handle them and show the message.
- Fast mode does not check whether the mailbox exists. Run /v1/verify after sign-up, for example from a Firestore trigger, if bounces matter.
Firebase Authentication documentation
Firebase Authentication is a trademark of its owner. This integration uses Firebase Authentication's documented extension points; it is not an official Firebase Authentication app.
Common questions
- Does beforeUserCreated run for Google or Apple sign-in too?
- Yes, it runs for new accounts from any provider. OAuth providers have already verified the address, so most teams only act on verdict.is_spam there, and skip phone and anonymous users that have no email.
- What does the user see when the function rejects them?
- Firebase returns an error to the client SDK. Catch it in your sign-up code and show your own message, such as asking for a permanent address.
Stop bad addresses in Firebase Authentication today
Sign in with your email, create an API key and paste it into the step above. Test on a few real addresses first: the live demo shows exactly what your Firebase Authentication setup will receive.