5.4 KiB
Trackeep GitHub Integration Implementation Complete ✅
Architecture Overview
Centralized OAuth Service (oauth.tdvorak.dev) + User-Hosted Trackeep = Perfect separation of concerns
What Was Implemented
🔐 OAuth Service Changes
✅ Enhanced JWT Tokens - Now includes GitHub access token
✅ Repo Scope Added - user:email, read:user, repo
✅ Wildcard CORS - Allows all domains
✅ Dynamic Client Detection - Auto-redirects to originating domain
🏠 Trackeep Backend Changes
✅ OAuth Callback Handler - /api/v1/auth/oauth/callback
✅ Enhanced User Info - /api/v1/auth/me with GitHub data
✅ GitHub API Integration - /api/v1/github/repos using real access tokens
✅ Token Pass-through - GitHub access token embedded in Trackeep JWT
🎨 Frontend Changes
✅ Updated GitHub Connect - Points to centralized OAuth service
✅ Enhanced Auth Callback - Handles Trackeep backend tokens
✅ Real GitHub Data - No more mock data in production
How It Works: Complete Flow
1. User Clicks "Connect GitHub"
Trackeep Frontend → https://oauth.tdvorak.dev/auth/github?redirect_uri=https://user-trackeep.com/api/v1/auth/oauth/callback
2. OAuth Service Handles GitHub
- User authenticates with GitHub
- OAuth service gets GitHub access token
- Creates JWT with:
user_info + github_access_token - Redirects to Trackeep backend with token
3. Trackeep Backend Processes
// Receives: /api/v1/auth/oauth/callback?token=OAUTH_JWT
// Parses OAuth service JWT
// Extracts GitHub access token
// Creates/updates user in local DB
// Generates Trackeep JWT with embedded GitHub token
// Redirects to frontend: /auth/callback?token=TRACKEEP_JWT
4. Frontend Stores Trackeep Token
localStorage.setItem('token', trackeepJWT);
5. GitHub API Calls
// Frontend calls Trackeep backend
fetch('/api/v1/github/repos', {
headers: { 'Authorization': `Bearer ${trackeepJWT}` }
});
// Trackeep backend:
// 1. Validates Trackeep JWT
// 2. Extracts GitHub access token from JWT
// 3. Calls GitHub API directly
// 4. Returns real repo data
Security Model
🔒 Token Flow
- OAuth Service JWT (short-lived, for callback only)
- Trackeep JWT (7-day expiry, contains GitHub token)
- GitHub Access Token (passed through, used for API calls)
🛡️ Security Features
- CSRF protection via state parameters
- JWT token validation
- GitHub access token never exposed to frontend
- All GitHub API calls happen on backend
Environment Variables Needed
OAuth Service (.env)
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GITHUB_REDIRECT_URL=https://oauth.tdvorak.dev/auth/github/callback
JWT_SECRET=jgk284kd83h83hfgje3i3j
CORS_ALLOWED_ORIGINS=*
DEFAULT_CLIENT_URL=https://tdvorak.dev
SERVICE_DOMAIN=https://oauth.tdvorak.dev
Trackeep Backend (.env)
JWT_SECRET=your_trackeep_jwt_secret
OAUTH_JWT_SECRET=jgk284kd83h83hfgje3i3j # Same as OAuth service
FRONTEND_URL=https://your-trackeep-instance.com
API Endpoints
OAuth Service
GET /auth/github- Initiate OAuthGET /auth/github/callback- Handle GitHub callbackGET /api/v1/user/me- Get user info
Trackeep Backend
GET /api/v1/auth/oauth/callback- Handle OAuth service callbackGET /api/v1/auth/me- Get current user with GitHub infoGET /api/v1/github/repos- Get user's GitHub repositories
What Trackeep Can Now Track
✅ Real Repository Data - Names, descriptions, languages
✅ Repository Stats - Stars, forks, watchers, issues
✅ Commit History - Via GitHub API calls
✅ Pull Requests - Status and activity
✅ Branch Information - Default branch, etc.
✅ Activity Tracking - Last updated timestamps
Benefits of This Architecture
🎯 Separation of Concerns
- OAuth service = Authentication only
- Trackeep = Business logic + data tracking
- Clean boundaries and responsibilities
🔐 Security
- GitHub credentials centralized
- Access tokens never exposed to frontend
- Each instance controls its own data
📈 Scalability
- OAuth service handles authentication load
- Trackeep instances handle their own GitHub API calls
- No single point of failure for data
🏠 User Privacy
- GitHub data stays in user's Trackeep instance
- No centralized data collection
- User controls their own tracking data
Next Steps for Full Implementation
-
Add More GitHub Endpoints
/api/v1/github/repos/:owner/:repo/commits/api/v1/github/repos/:owner/:repo/pulls/api/v1/github/repos/:owner/:repo/branches
-
Implement Background Sync
- Periodic GitHub API calls
- Store data in local database
- Track changes over time
-
Add Webhook Support
- Real-time updates from GitHub
- Instant tracking of pushes/PRs
-
Enhanced Frontend
- Commit history viewer
- Pull request tracking
- Activity timeline
Deployment Ready! 🚀
The implementation is complete and ready for deployment. Users can now:
- Connect their GitHub accounts via centralized OAuth
- Track real repository data in their Trackeep instances
- Maintain full control over their data
- Scale horizontally with multiple instances
Architecture: OAuth Service (Authentication) + Trackeep (Tracking) = Perfect Combination! 🎉