Skip to content

Security: chrisbraycodes/My-Reads

Security

SECURITY.md

Security Information

Is My Repo Safe to Be Public?

Short answer: Yes, your repo can be public, but you should take some precautions.

What's Safe βœ…

  1. User Data: All user data (books, profiles, etc.) is stored in Firestore and protected by Firebase Security Rules. The API key alone cannot access user data.

  2. Firebase API Keys: Firebase API keys are designed to be public. They're included in client-side code and visible to anyone. Security comes from:

    • Firestore Security Rules (which you've configured)
    • API Key Restrictions (which you should set up - see below)

What You Should Do πŸ”’

1. Set Up API Key Restrictions (Recommended)

Even though API keys are public, you should restrict them to prevent abuse:

  1. Go to Google Cloud Console
  2. Select your Firebase project (my-reads-52323)
  3. Go to APIs & Services > Credentials
  4. Find your API key (AIzaSyAkQsFGVLmB9M1IkWJsLt-dFLzYtRI3eWY)
  5. Click Edit
  6. Under Application restrictions, select:
    • HTTP referrers (web sites)
    • Add your domains:
      • http://localhost:3000/* (for development)
      • https://my-reads-blush.vercel.app/* (your production domain)
      • https://*.vercel.app/* (if you use preview deployments)
  7. Under API restrictions, select:
    • Restrict key
    • Select only: Firebase Authentication API and Cloud Firestore API
  8. Click Save

This prevents others from using your API key on unauthorized domains or for unauthorized APIs.

2. Use Environment Variables (Best Practice)

The code now supports environment variables. Create a .env file (it's already in .gitignore):

cp .env.example .env

Then fill in your Firebase config values. For production (Vercel), add these as environment variables in your Vercel project settings.

3. Verify Firestore Security Rules

Make sure your Firestore security rules are properly configured. They should:

  • βœ… Allow users to read/write only their own data
  • βœ… Allow unauthenticated users to read public profiles only
  • βœ… Prevent unauthorized access to private data

4. Rotate API Key (Optional, if concerned)

If you're worried about the exposed API key, you can rotate it:

  1. Go to Firebase Console > Project Settings > General
  2. Scroll to "Your apps" > Web app
  3. Click the settings icon > Regenerate key
  4. Update your .env file and Vercel environment variables

Note: This won't remove the old key from git history, but it will invalidate it.

What's NOT Exposed βœ…

  • βœ… User passwords (handled by Firebase Auth)
  • βœ… GitHub OAuth secrets (stored in Firebase Console, not in code)
  • βœ… Google OAuth secrets (stored in Firebase Console, not in code)
  • βœ… Firestore data (protected by security rules)
  • βœ… User authentication tokens (managed by Firebase)

Summary

Your repo is safe to be public as long as:

  1. βœ… Firestore security rules are properly configured (they are)
  2. βœ… API key restrictions are set up (recommended)
  3. βœ… No actual secrets are hardcoded (there aren't)

The Firebase API key being visible is normal and expected for client-side Firebase apps. The real security comes from your Firestore security rules, which you've already configured correctly.

There aren’t any published security advisories