|
| 1 | +# GitHub OAuth Deployment Guide |
| 2 | + |
| 3 | +This guide explains how to set up GitHub OAuth authentication for the review submission system. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The review submission system uses GitHub OAuth to authenticate users. This requires a serverless function to securely exchange the OAuth authorization code for an access token (since the client secret cannot be exposed in client-side JavaScript). |
| 8 | + |
| 9 | +## Option 1: Deploy to Vercel (Recommended) |
| 10 | + |
| 11 | +1. **Install Vercel CLI** (if not already installed): |
| 12 | + ```bash |
| 13 | + npm i -g vercel |
| 14 | + ``` |
| 15 | + |
| 16 | +2. **Deploy the API function**: |
| 17 | + ```bash |
| 18 | + vercel |
| 19 | + ``` |
| 20 | + |
| 21 | +3. **Set environment variables in Vercel Dashboard**: |
| 22 | + - Go to your project settings → Environment Variables |
| 23 | + - Add: |
| 24 | + - `GITHUB_CLIENT_ID` - Your GitHub OAuth App Client ID |
| 25 | + - `GITHUB_CLIENT_SECRET` - Your GitHub OAuth App Client Secret |
| 26 | + - `GITHUB_REDIRECT_URI` - Your redirect URI (e.g., `https://singularitynet-archive.github.io/Graph-Python-scripts`) |
| 27 | + |
| 28 | +4. **Update the API endpoint in `docs/script.js`**: |
| 29 | + ```javascript |
| 30 | + const serverlessUrl = 'https://your-project.vercel.app/api/github-auth'; |
| 31 | + ``` |
| 32 | + |
| 33 | +## Option 2: Deploy to Netlify |
| 34 | + |
| 35 | +1. **Place the function** in `netlify/functions/github-auth.js` (already created) |
| 36 | + |
| 37 | +2. **Deploy to Netlify**: |
| 38 | + ```bash |
| 39 | + netlify deploy --prod |
| 40 | + ``` |
| 41 | + |
| 42 | +3. **Set environment variables in Netlify Dashboard**: |
| 43 | + - Go to Site settings → Environment variables |
| 44 | + - Add the same variables as above |
| 45 | + |
| 46 | +4. **Update the API endpoint in `docs/script.js`**: |
| 47 | + ```javascript |
| 48 | + const serverlessUrl = 'https://your-site.netlify.app/.netlify/functions/github-auth'; |
| 49 | + ``` |
| 50 | + |
| 51 | +## Option 3: AWS Lambda / Cloudflare Workers |
| 52 | + |
| 53 | +Similar process - deploy the serverless function and set environment variables. |
| 54 | + |
| 55 | +## Creating a GitHub OAuth App |
| 56 | + |
| 57 | +1. Go to https://github.com/settings/developers |
| 58 | +2. Click "New OAuth App" |
| 59 | +3. Fill in: |
| 60 | + - **Application name**: Graph Analysis Review System |
| 61 | + - **Homepage URL**: https://singularitynet-archive.github.io/Graph-Python-scripts |
| 62 | + - **Authorization callback URL**: Same as homepage URL |
| 63 | +4. Click "Register application" |
| 64 | +5. Copy the **Client ID** and generate a **Client Secret** |
| 65 | +6. Add these to your serverless function environment variables |
| 66 | + |
| 67 | +## Testing |
| 68 | + |
| 69 | +1. Submit a review on the GitHub Pages site |
| 70 | +2. You should be redirected to GitHub for authorization |
| 71 | +3. After authorizing, you'll be redirected back |
| 72 | +4. The token will be stored locally and used for future submissions |
| 73 | + |
| 74 | +## Security Notes |
| 75 | + |
| 76 | +- Never expose the `GITHUB_CLIENT_SECRET` in client-side code |
| 77 | +- Always use HTTPS for OAuth redirects |
| 78 | +- Tokens are stored locally in the user's browser (localStorage) |
| 79 | +- Tokens can be revoked by users in their GitHub settings |
| 80 | + |
0 commit comments