Skip to content

Commit 0546d52

Browse files
committed
add go backend
1 parent 57bbda6 commit 0546d52

6 files changed

Lines changed: 924 additions & 165 deletions

File tree

README.md

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,82 @@
11
# GitHub PR Dashboard
22

3-
A lightweight, fast dashboard for viewing GitHub pull requests. Built with plain HTML, CSS, and JavaScript for maximum performance and simplicity.
3+
A lightweight, fast dashboard for viewing GitHub pull requests. Can be served statically or via the included secure Go server with OAuth support.
44

55
## Features
66

7-
- **Real GitHub Integration**: Login with GitHub OAuth to view your actual pull requests
8-
- **Smart Categorization**: Automatically groups PRs into Incoming (for review), Outgoing (authored by you), and Drafts
9-
- **Visual Status Indicators**: Color-coded cards and badges show PR status at a glance
10-
- **Activity Sparklines**: See PR activity trends for each section
11-
- **Organization Filtering**: Filter PRs by GitHub organization
7+
- **Real GitHub Integration**: Login with GitHub OAuth or Personal Access Token
8+
- **Smart Categorization**: Automatically groups PRs into Incoming, Outgoing, and Drafts
9+
- **Visual Status Indicators**: Color-coded cards show PR status at a glance
10+
- **Security Hardened Go Server**: Optional server with comprehensive security features
1211
- **Demo Mode**: Try the interface with sample data before logging in
13-
- **URL-based User Switching**: View other users' PRs by adding `?user=username` to the URL
1412

1513
## Quick Start
1614

17-
1. Open `index.html` in a web browser
18-
2. Click "Try Demo Mode" to see the interface with sample data, or
19-
3. Login with GitHub to view your real pull requests
20-
21-
## Status Indicators
15+
### Static Files (Simple)
16+
```bash
17+
# Just open in browser
18+
open index.html
19+
```
2220

23-
- 🔴 **Blocked on you**: PRs requiring your immediate attention
24-
- 🟡 **Stale**: PRs older than 30 days
25-
- 🟢 **Ready to merge**: PRs approved and ready for merging
26-
- 🟠 **Merge conflicts**: PRs with conflicts that need resolution
27-
-**Draft**: Work-in-progress pull requests
21+
### Go Server (OAuth + Security)
22+
```bash
23+
go build
24+
# Client ID defaults to Iv23liYmAKkBpvhHAnQQ
25+
./dashboard --port=8080 --client-secret=YOUR_SECRET
26+
```
2827

29-
## GitHub OAuth Setup
28+
## Go Server Features
29+
30+
### Security
31+
- **CSRF Protection**: Secure state validation
32+
- **Rate Limiting**: 10 req/min per IP on OAuth endpoints
33+
- **Security Headers**: CSP, X-Frame-Options, HSTS, etc.
34+
- **Request Tracking**: Unique IDs and security event logging
35+
- **Origin Validation**: Configurable CORS with `--allowed-origins`
36+
37+
### Configuration
38+
```bash
39+
# Environment variables
40+
PORT=8080 GITHUB_CLIENT_ID=xxx GITHUB_CLIENT_SECRET=yyy ./dashboard
41+
42+
# Command line flags
43+
# Defaults: client-id=Iv23liYmAKkBpvhHAnQQ, redirect-uri=https://dash.ready-to-review.dev/oauth/callback
44+
./dashboard \
45+
--port=8080 \
46+
--client-secret=yyy \
47+
--redirect-uri=http://localhost:8080/oauth/callback \
48+
--allowed-origins=http://localhost:8080
49+
```
3050

31-
See [README_OAUTH.md](README_OAUTH.md) for instructions on setting up GitHub OAuth authentication.
51+
### Endpoints
52+
- `GET /` - Dashboard
53+
- `GET /health` - Health check
54+
- `GET /oauth/login` - Start OAuth flow
55+
- `GET /oauth/callback` - OAuth callback
3256

33-
## URL Parameters
57+
## GitHub OAuth Setup
3458

35-
- `?demo=true` - Launch in demo mode with sample data
36-
- `?user=username` - View a specific GitHub user's pull requests (requires authentication)
59+
1. Create OAuth App at GitHub Settings > Developer settings > OAuth Apps
60+
2. Set callback URL to `https://dash.ready-to-review.dev/oauth/callback` (or your custom URL)
61+
3. Use the client secret with the Go server (client ID defaults to Iv23liYmAKkBpvhHAnQQ)
3762

38-
## Technical Details
63+
## Security Best Practices
3964

40-
- **Zero Dependencies**: Pure HTML, CSS, and JavaScript (except for demo data)
41-
- **Responsive Design**: Works on desktop and mobile devices
42-
- **Accessible**: ARIA labels and semantic HTML for screen readers
43-
- **Fast**: Minimal JavaScript, efficient DOM updates
44-
- **Clean Code**: Well-organized, commented code following best practices
65+
When using the Go server:
66+
- **Always use HTTPS in production** - Enables HSTS automatically
67+
- **Set allowed origins** - Use `--allowed-origins` for your domains
68+
- **Monitor logs** - Watch for `[SECURITY]` tagged events
69+
- **Keep updated** - Regular updates for security patches
4570

4671
## File Structure
4772

4873
```
49-
├── index.html # Main application HTML
50-
├── assets/
51-
│ ├── app.js # Application JavaScript
52-
│ ├── styles.css # Application styles
53-
│ └── demo-data.js # Demo mode sample data
54-
└── README_OAUTH.md # OAuth setup instructions
74+
├── index.html # Dashboard UI
75+
├── main.go # Secure Go server
76+
├── assets/ # CSS, JS, demo data
77+
└── go.mod # Go module file
5578
```
5679

57-
## Browser Support
58-
59-
- Chrome/Edge (latest)
60-
- Firefox (latest)
61-
- Safari (latest)
62-
- Mobile browsers (iOS Safari, Chrome)
63-
64-
## Contributing
65-
66-
This is a simple, focused application. If you'd like to contribute:
67-
68-
1. Keep it simple - no frameworks or build tools
69-
2. Maintain backward compatibility
70-
3. Test on multiple browsers
71-
4. Follow the existing code style
72-
7380
## License
7481

7582
MIT

README_OAUTH.md

Lines changed: 0 additions & 102 deletions
This file was deleted.

assets/app.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,17 @@ const App = (() => {
665665

666666
// Auth Functions
667667
const initiateOAuthLogin = () => {
668-
const authUrl = `https://github.com/login/oauth/authorize?client_id=${CONFIG.CLIENT_ID}&redirect_uri=${encodeURIComponent(CONFIG.OAUTH_REDIRECT_URI)}&scope=repo%20read:org`;
669-
window.location.href = authUrl;
668+
// Use the Go backend's OAuth endpoint
669+
const authWindow = window.open('/oauth/login', 'github-oauth', 'width=600,height=700');
670+
671+
// Listen for OAuth callback
672+
window.addEventListener('message', async (event) => {
673+
if (event.data && event.data.type === 'oauth-callback' && event.data.token) {
674+
storeToken(event.data.token);
675+
authWindow.close();
676+
await initialize();
677+
}
678+
});
670679
};
671680

672681
const initiatePATLogin = () => {
@@ -708,17 +717,8 @@ const App = (() => {
708717
};
709718

710719
const handleOAuthCallback = async () => {
711-
const urlParams = new URLSearchParams(window.location.search);
712-
const code = urlParams.get('code');
713-
714-
if (code) {
715-
// In a real implementation, you'd exchange this code for a token
716-
// via your backend server. For now, we'll show an error message.
717-
showToast('OAuth authentication requires a backend server. Please use Personal Access Token instead.', 'warning');
718-
// Clean up URL
719-
window.history.replaceState({}, document.title, window.location.pathname);
720-
showLoginPrompt();
721-
}
720+
// OAuth is now handled via popup window and postMessage
721+
// This function is kept for backwards compatibility but does nothing
722722
};
723723

724724
const initiateLogin = () => {

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/r2r/dashboard
2+
3+
go 1.21

hacks/deploy.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
PROJECT="ready-to-review"
3+
export KO_DOCKER_REPO="gcr.io/${PROJECT}/dashboard"
4+
5+
gcloud run deploy dashboard --image="$(ko publish .)" --region us-central1 --project "${PROJECT}"

0 commit comments

Comments
 (0)