- β
.envremoved from Git tracking - β
.envadded to.gitignore - β
.env.exampleprovides template with instructions - β README.md includes security warnings
MANDATORY SECURITY CHECKS:
-
Verify .env is NOT tracked:
git ls-files | grep -E '\.env$' # Should return NO results (only .env.example should exist)
-
Confirm .gitignore includes .env:
grep -E '\.env' .gitignore # Should show .env patterns
-
Check for accidental commits:
git log --all --full-history -- .env # If this shows results, see "π¨ If .env Was Already Committed" below
If your .env file with real credentials was ever committed to a repository:
-
Immediately rotate your Supabase keys:
- Go to Supabase Dashboard > Settings > API
- Reset your anon key
- Update your local
.envwith new keys
-
Remove from Git history (if repository is private):
git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch .env' \ --prune-empty --tag-name-filter cat -- --all -
For public repositories:
- Create a new Supabase project
- Update all your environment variables
- Consider the old keys compromised
- β All Supabase tables have RLS enabled
- β Users can only access their own data
- β Anonymous users cannot access authenticated data
// In src/lib/supabase.ts
if (!SUPABASE_URL || !SUPABASE_ANON_KEY) {
console.warn('Supabase env vars not found. Supabase sync will be disabled.');
}- Set environment variables in dashboard (not in code)
- Use different Supabase project for production
- Never use development keys in production
- Use Docker secrets or environment files
- Never include
.envin Docker images - Use build-time arguments for public variables only
-
.envis in.gitignore -
.envis not tracked by Git - No credentials hardcoded in source files
-
.env.examplehas dummy values only - Production uses separate Supabase project
- RLS policies are properly configured
- Environment variables set in deployment platform
# Final check before pushing
git status
git ls-files | grep -E '\.env$' # Should be empty
# Safe to push
git add .
git commit -m "feat: add authentication and database integration"
git push origin mainIf credentials are accidentally exposed:
- Immediately rotate Supabase keys
- Check repository access logs
- Monitor Supabase usage for unusual activity
- Consider creating new Supabase project if exposure was public
Remember: It's always better to be overly cautious with credentials than to deal with a security incident later!