- Implement server-side OAuth handlers for Discord, Roblox, GitHub - Add OAuth routes with state validation and PKCE support - Create comprehensive documentation (setup, rotation, quickstart) - Add .env to .gitignore to protect credentials
9.4 KiB
Credentials Rotation Guide
🚨 Security Incident Response
If credentials are compromised (e.g., accidentally committed to git or shared publicly), follow this guide IMMEDIATELY.
🔄 Rotation Priority Order
🔴 CRITICAL (Rotate Immediately)
- Discord Bot Token - Full bot control
- Stripe Secret Key - Payment processing access
- GitHub Personal Access Token - Repository access
🟡 HIGH (Rotate Before Production)
- Discord Client Secret - OAuth access
- Roblox Client Secret - OAuth access
- Roblox Open Cloud API Key - API access
- Stripe Webhook Secret - Webhook validation
🟢 MEDIUM (Rotate When Convenient)
- Discord Public Key - Webhook signature verification
- GitHub Client ID/Secret - OAuth (once registered)
🎮 Discord Credentials Rotation
1. Bot Token
Why: Full control over bot actions, can read/send messages, access servers
- Go to Discord Developer Portal
- Select your application
- Navigate to Bot section
- Click Reset Token
- Copy new token to
.env:DISCORD_BOT_TOKEN=NEW_TOKEN_HERE - Restart your application
2. Client Secret
Why: Used for OAuth token exchange
- In Discord Developer Portal, go to OAuth2 section
- Click Reset Secret
- Copy new secret to
.env:DISCORD_CLIENT_SECRET=NEW_SECRET_HERE - Restart your application
3. Public Key
Why: Used to verify webhook signatures (less critical but good practice)
- In General Information section
- Click Regenerate next to Public Key
- Update
.env:DISCORD_PUBLIC_KEY=NEW_KEY_HERE
🎲 Roblox Credentials Rotation
1. Client Secret
Why: Used for OAuth token exchange
- Go to Roblox Creator Dashboard
- Find your OAuth 2.0 credential
- Click Regenerate Secret
- Copy new secret to
.env:ROBLOX_CLIENT_SECRET=NEW_SECRET_HERE - Restart your application
2. Open Cloud API Key
Why: Server-to-server API access
- In Creator Dashboard, go to API Keys
- Find the compromised key
- Click Delete to revoke it
- Create new API key with same permissions
- Copy to
.env:ROBLOX_OPEN_CLOUD_API_KEY=NEW_KEY_HERE - Restart your application
Note: Old API key stops working immediately upon deletion.
🐙 GitHub Credentials Rotation
1. Personal Access Token
Why: Repository and API access
- Go to GitHub Personal Access Tokens
- Find the compromised token
- Click Delete to revoke it
- Generate new token:
- Click Generate new token (classic)
- Select same scopes as before
- Set expiration (recommend 90 days)
- Copy to
.env:GITHUB_PERSONAL_ACCESS_TOKEN=NEW_TOKEN_HERE - Restart your application
Note: Old token stops working immediately upon deletion.
2. OAuth Client Secret
When you register OAuth app:
- Go to GitHub Developer Settings
- Select your OAuth app
- Click Generate a new client secret
- Copy to
.env:GITHUB_CLIENT_SECRET=NEW_SECRET_HERE
💳 Stripe Credentials Rotation
1. Secret Key
Why: Full payment processing access - HIGHEST RISK
- Go to Stripe Dashboard
- Click Reveal test key or Reveal live key
- Click Roll secret key
- Confirm the rollover
- Copy new key to
.env:STRIPE_SECRET_KEY=NEW_KEY_HERE - Deploy immediately - old key has grace period
⚠️ Important:
- Old key works for 24-48 hours (grace period)
- Deploy new key ASAP to avoid disruption
- Test payments after deployment
2. Webhook Secret
Why: Validates webhook authenticity
- Go to Developers → Webhooks
- Click your webhook endpoint
- Click Roll secret
- Copy new secret to
.env:STRIPE_WEBHOOK_SECRET=NEW_SECRET_HERE - Restart your application
Note: Old webhooks will fail signature validation immediately.
🔐 Supabase Credentials (If Needed)
Anon Key
Lower risk - designed to be public, but rotation doesn't hurt
- Go to Supabase Dashboard
- Navigate to Settings → API
- Click Generate new anon key (if available)
- Update
.env:SUPABASE_ANON_KEY=NEW_KEY_HERE VITE_SUPABASE_ANON_KEY=NEW_KEY_HERE
Service Role Key
CRITICAL - full database access
- In Supabase Dashboard, go to Settings → API
- Click Rotate service_role key
- Update server-side env (never expose to client)
- Restart all server instances
✅ Post-Rotation Checklist
After rotating credentials:
1. Environment Variables
- Updated
.envfile with all new credentials - Verified no typos in new keys
- Confirmed
.envis in.gitignore - Deleted old
.envbackups
2. Application Deployment
- Restarted local development server
- Tested OAuth flows with new credentials
- Verified webhook signatures validate
- Tested API calls work correctly
3. Production Deployment (When Ready)
- Updated production environment variables
- Deployed application with zero downtime
- Monitored logs for authentication errors
- Verified no legacy credential usage
4. Documentation
- Updated internal team docs with new setup
- Documented rotation date in security log
- Set calendar reminder for next rotation (90 days)
5. Access Control
- Removed compromised credentials from all locations:
- Chat logs (can't delete, but rotate makes them useless)
- Clipboard history
- Shell history (
history -c) - Git reflog (if accidentally committed)
🗓️ Rotation Schedule
Recommended Rotation Frequency
| Credential | Frequency | Priority |
|---|---|---|
| Stripe Secret Key | Every 90 days | 🔴 Critical |
| Bot Tokens | Every 90 days | 🔴 Critical |
| Personal Access Tokens | Every 90 days | 🟡 High |
| OAuth Client Secrets | Every 180 days | 🟡 High |
| API Keys | Every 180 days | 🟡 High |
| Webhook Secrets | Every 180 days | 🟢 Medium |
| Public Keys | Annually | 🟢 Medium |
Set Reminders
# Add to calendar or use cron job:
0 0 1 */3 * * echo "Rotate Stripe/Discord credentials" | mail admin@aethex.app
🚨 Git History Cleanup (If Committed)
If credentials were accidentally committed to git:
Option 1: BFG Repo-Cleaner (Recommended)
# Install BFG
brew install bfg # or download from https://rtyley.github.io/bfg-repo-cleaner/
# Clone a fresh copy
git clone --mirror https://github.com/AeThex-Corporation/AeThex-OS.git
# Remove .env files from history
bfg --delete-files .env AeThex-OS.git
# Clean up
cd AeThex-OS.git
git reflog expire --expire=now --all
git gc --prune=now --aggressive
# Force push (⚠️ DESTRUCTIVE)
git push --force
Option 2: git-filter-repo
# Install git-filter-repo
pip install git-filter-repo
# Remove .env from history
git filter-repo --path .env --invert-paths
# Force push
git push origin --force --all
⚠️ Warning: Force pushing rewrites history. Coordinate with team!
📞 Emergency Contacts
If credentials are actively being abused:
Discord
- Report abuse: https://dis.gd/report
- Developer support: https://discord.com/developers/docs
Stripe
- Emergency contact: https://support.stripe.com/
- Phone support: Available for paid plans
GitHub
- Security incidents: security@github.com
- Support: https://support.github.com/
Roblox
- Security: security@roblox.com
- Support: https://www.roblox.com/support
🧪 Testing After Rotation
Run these commands to verify new credentials work:
# Test Discord OAuth
curl "https://discord.com/api/oauth2/authorize?client_id=${DISCORD_CLIENT_ID}&redirect_uri=http://localhost:5000/api/oauth/callback/discord&response_type=code&scope=identify"
# Test Stripe API
curl https://api.stripe.com/v1/balance \
-u ${STRIPE_SECRET_KEY}:
# Test GitHub API
curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" \
https://api.github.com/user
# Test Roblox Open Cloud
curl -H "x-api-key: ${ROBLOX_OPEN_CLOUD_API_KEY}" \
https://apis.roblox.com/cloud/v2/users/${USER_ID}
📝 Security Best Practices
Prevention
- Never commit credentials - Use
.envand add to.gitignore - Use environment-specific credentials - Separate dev/staging/prod
- Rotate proactively - Don't wait for incidents
- Monitor usage - Watch API logs for suspicious activity
- Least privilege - Grant minimum permissions needed
Detection
- Enable webhook alerts - Get notified of unusual API usage
- Monitor git commits - Use pre-commit hooks to scan for secrets
- Audit logs - Review provider dashboards regularly
- Automated scanning - Use tools like
git-secretsortrufflehog
Response
- Have this document ready - Don't scramble during incidents
- Test rotation process - Practice on dev environment first
- Document incidents - Learn from mistakes
- Automate where possible - Use secret management tools
Last Updated: December 24, 2025
Next Review: March 24, 2026