β All secrets are protected:
- Firebase API keys use environment variables
- GitHub tokens use environment variables
- No hardcoded secrets in code
.envfile is in.gitignore
-
Firebase Configuration:
- API Key
- Project ID
- Storage Bucket
- Messaging Sender ID
- App ID
- Measurement ID
-
GitHub Token:
- Personal Access Token
firebase-config.js- UsesVITE_FIREBASE_API_KEYplaceholderjs/github-api.js- UsesVITE_GITHUB_TOKENplaceholderapp.js- UsesVITE_GITHUB_TOKENplaceholderbuild.js- Injects environment variables at build time
- β
.envis in.gitignore - β
.env.local,.env.productionare ignored - β Pre-commit hook prevents committing secrets
- β GitHub Actions scan for secrets
Secrets are injected at build time, not in source code:
// Source code (safe to commit)
const firebaseConfig = {
apiKey: "VITE_FIREBASE_API_KEY"
};
// After build (with real values, not committed)
const firebaseConfig = {
apiKey: "AIzaSy..." // Real key from environment
};GitHub Actions run on every PR:
- β Scan for hardcoded secrets
- β
Verify
.envnot in git - β
Check
.gitignoreconfiguration - β Validate environment variable placeholders
- β
Verify
.env.exampleis safe
Before pushing code, verify:
- No
.envfile in git (git statusshould not show.env) - No hardcoded API keys in code
- No hardcoded tokens in code
- All secrets use environment variables
-
.env.exampleexists (without real values) -
.gitignoreincludes.env
-
Rotate all exposed secrets:
- Generate new Firebase API keys
- Generate new GitHub token
- Revoke old tokens/keys
-
Update environment variables:
- Update
.envfile locally - Update Netlify environment variables
- Update any CI/CD systems
- Update
-
Clean git history (if needed):
# Use BFG Repo-Cleaner or git-filter-repo # to remove secrets from git history
-
Notify team:
- Inform all team members
- Update documentation
- Review access logs
π How to Verify Secrets Are Hidden
# Check if .env is tracked
git ls-files | grep .env
# Search for hardcoded secrets
grep -r "AIzaSy" --include="*.js" --exclude-dir=node_modules .
grep -r "ghp_" --include="*.js" --exclude-dir=node_modules .
# Should only find placeholders like "VITE_FIREBASE_API_KEY"# Clone the repo
git clone <repo-url>
cd <repo-name>
# Check source files (should only have placeholders)
grep "VITE_FIREBASE_API_KEY" firebase-config.js
grep "VITE_GITHUB_TOKEN" js/github-api.js
# Should find placeholders, NOT real valuesWhen you download the project from GitHub:
-
Source files contain placeholders:
// firebase-config.js apiKey: "VITE_FIREBASE_API_KEY" // Placeholder, not real key
-
No
.envfile:- You need to create your own
- Copy from
.env.example - Add your own credentials
-
Build requires environment variables:
- Run
npm run buildwith.envfile - Build script replaces placeholders
- Built files contain real values (not committed)
- Run
- β Real Firebase API keys
- β Real GitHub tokens
- β Any production secrets
- β
.envfile with real values
VITE_FIREBASE_API_KEY=your_key_here
VITE_FIREBASE_AUTH_DOMAIN=your_domain_here
VITE_FIREBASE_PROJECT_ID=your_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_bucket_here
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id
VITE_FIREBASE_MEASUREMENT_ID=your_measurement_id
VITE_GITHUB_TOKEN=your_token_here # Optional- Firebase: Firebase Console
- GitHub: GitHub Settings β Tokens
- Never commit
.envfile - Never hardcode secrets
- Always use environment variables
- Rotate secrets regularly
- Use different secrets for dev/prod
- Review PRs for secret exposure
- Use pre-commit hooks
- Enable automated security scans
- β Pre-commit hook checks
- β GitHub Actions security scan
- β Secret detection in PRs
- β Environment variable validation
# 1. Check .env is ignored
git check-ignore .env
# 2. Search for secrets
grep -r "AIzaSy\|ghp_" --include="*.js" .
# 3. Verify placeholders
grep "VITE_" firebase-config.js js/github-api.jsRemember: Security is everyone's responsibility! π