Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8807e07
Project Ember (Restyle) Inital Commitment
Jun 28, 2025
91e137e
Add notice management and user management pages with enhanced UI
Jun 29, 2025
89916f1
fix: hide notice actions for inactive users to improve UI clarity
Jun 29, 2025
e5a77c3
chore: remove unused test database file to clean up the repository
Jun 30, 2025
ba03253
feat: add session expiration logic to user serialization and deserial…
Jun 30, 2025
58b1ac5
Removed Node_ENV because its useless, added reason why database URL i…
Jun 30, 2025
be50c28
made it a joke because the last on even through its ment to be a reas…
Jun 30, 2025
e3bbc16
fix: update changelog link to use relative URL for consistency
Jul 3, 2025
4f31fe7
fix: remove fallback callback URL for GitHub strategy to enforce envi…
Jul 3, 2025
c24a475
fix: enhance GitHub OAuth error handling and configuration checks
Jul 3, 2025
a6c5cb0
fix: add GitHub OAuth environment variables to Docker Compose files
Jul 3, 2025
2f9b454
fix: enhance session management with cleanup for expired sessions
Jul 3, 2025
f22277b
fixed docker-compose
Jul 3, 2025
e184732
fix: update session cookie name to 'vorel.sid' for consistency
Jul 3, 2025
0149903
feat: implement FRC Nexus webhook support and statistics tracking
Jul 4, 2025
04ab492
fix: enhance webhook token verification and improve error logging for…
Jul 4, 2025
b4ef38b
fix: streamline logging messages in Nexus webhook endpoint for clarity
Jul 4, 2025
b6c5062
fix: update system status to reflect webhook configuration state in a…
Jul 4, 2025
6b66619
fix: remove test webhook endpoint for debugging from API routes for s…
Jul 4, 2025
fe42610
fix: remove sample notice creation script to streamline codebase
Jul 4, 2025
1e41576
hopefully this works? seperated login style sheet from login's page f…
Jul 8, 2025
b77842b
updated nodejs in dockerfile to use latest node.js alpine
Jul 8, 2025
44e15b4
fix: correct JSON formatting in home.ejs script tag
Aug 11, 2025
f2049ed
Merge https://github.com/1334robotics/vorel-app into ember
Oct 22, 2025
f6a2f93
chore: upgrade dependencies and regenerate lockfile
Oct 22, 2025
a77f2e2
chore: bump express-session to 1.18.2 in package-lock.json
Oct 22, 2025
aaa6cb1
fix: preserve JSON-LD blocks when stripping comments from rendered views
Oct 22, 2025
3c6caf9
Merge main into ember (preserving ember branch functionality)
Oct 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,34 @@
Nexus_Api_Key=API_KEY
TBA_API_Key=TBA_API_KEY

# Webhook Configuration
# Token for verifying incoming webhooks from FRC Nexus
# Get this from https://frc.nexus/api after registering your webhook endpoint
NEXUS_WEBHOOK_TOKEN=your_nexus_webhook_token_here

# Server Configuration
PORT=3002
NODE_ENV=development

# Database Configuration
# Why not URL? to be honest don't know.
DB_HOST=localhost
DB_PORT=3306
DB_NAME=vorel
DB_USER=vorel
DB_PASSWORD=your_secure_password_here
DB_ROOT_PASSWORD=your_root_password_here

# Authentication Configuration
# GitHub OAuth App credentials (create at https://github.com/settings/applications/new)
GITHUB_CLIENT_ID=your_github_client_id_here
GITHUB_CLIENT_SECRET=your_github_client_secret_here
GITHUB_CALLBACK_URL=http://localhost:3002/auth/github/callback

# Session secret for secure cookie signing
SESSION_SECRET=your_very_secure_random_session_secret_here

# Authorized GitHub users (comma-separated usernames)
# Leave empty to allow any GitHub user in development
AUTHORIZED_GITHUB_USERS=yourusername,anotheradmin

# Note: In production, make sure to use strong passwords and consider using Docker secrets
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
node_modules
.cache
.cache
.encryption-key.json
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:23-alpine
FROM node:current-alpine

WORKDIR /app

Expand Down
115 changes: 115 additions & 0 deletions GITHUB_OAUTH_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# GitHub OAuth Setup Guide

This guide will help you set up GitHub OAuth authentication for the Vorel admin panel.

## 1. Create a GitHub OAuth App

1. Go to [GitHub Developer Settings](https://github.com/settings/developers)
2. Click "New OAuth App"
3. Fill in the application details:
- **Application name**: `Vorel Admin` (or your preferred name)
- **Homepage URL**: `http://localhost:3002` (for development) or your production URL
- **Authorization callback URL**: `http://localhost:3002/auth/github/callback`
4. Click "Register application"
5. Copy the **Client ID** and **Client Secret**

## 2. Configure Environment Variables

Create a `.env` file in the root directory (copy from `.env.example`) and add:

```bash
# GitHub OAuth Configuration
GITHUB_CLIENT_ID=your_client_id_here
GITHUB_CLIENT_SECRET=your_client_secret_here
GITHUB_CALLBACK_URL=http://localhost:3002/auth/github/callback

# Session Secret (generate a secure random string)
SESSION_SECRET=your_very_secure_random_session_secret_here

# Authorized Users (comma-separated GitHub usernames)
AUTHORIZED_GITHUB_USERS=yourusername,teammate1,teammate2
```

## 3. Generate a Secure Session Secret

You can generate a secure session secret using Node.js:

```bash
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
```

## 4. Set Authorized Users

Add the GitHub usernames of people who should have admin access to the `AUTHORIZED_GITHUB_USERS` environment variable. Separate multiple usernames with commas.

**Important**: If this variable is empty or not set, anyone with a GitHub account can access the admin panel (useful for development, but not recommended for production).

## 5. Production Setup

For production:

1. Update the OAuth app settings in GitHub to use your production domain
2. Set `NODE_ENV=production` in your environment
3. Use a secure session secret
4. Consider using environment variable management tools or secrets management
5. Ensure HTTPS is enabled (required for secure cookies)

## 6. Testing

1. Start your server: `npm start`
2. Visit `http://localhost:3002/admin/notices`
3. You should be redirected to the login page
4. Click "Sign in with GitHub"
5. Authorize the application
6. You should be redirected back to the admin panel

## 7. Admin Panel Features

Once authenticated, you can:

- View all active notices
- Create new notices with different types (info, warning, success, danger)
- Edit existing notices
- Set notice priorities and expiration dates
- Deactivate or delete notices
- View your login status and logout

## 8. API Endpoints

The following admin API endpoints now require authentication:

- `POST /api/notices` - Create notice
- `PUT /api/notices/:id` - Update notice
- `DELETE /api/notices/:id` - Delete notice
- `POST /api/notices/:id/deactivate` - Deactivate notice

Public endpoints (no auth required):

- `GET /api/notices` - Get active notices (used by home page)

## 9. Troubleshooting

**"Missing required environment variables for GitHub OAuth"**
- Make sure you've set `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` in your `.env` file

**"User not authorized"**
- Check that your GitHub username is in the `AUTHORIZED_GITHUB_USERS` list
- Usernames are case-insensitive but must match exactly

**"Authentication failed"**
- Verify your OAuth app settings in GitHub
- Check that the callback URL matches exactly
- Ensure your client ID and secret are correct

**Session issues**
- Clear your browser cookies
- Check that `SESSION_SECRET` is set
- Restart the server after changing environment variables

## 10. Security Notes

- Never commit your `.env` file to version control
- Use strong, unique session secrets
- Regularly review and update authorized users
- Consider implementing additional security measures for production (rate limiting, etc.)
- Monitor authentication logs for suspicious activity
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,33 @@ cp .env.example .env
- Get a Nexus API key from [FIRST Nexus](https://frc.nexus)
- Get a TBA API key from [The Blue Alliance](https://www.thebluealliance.com/account)

### Real-time Updates Setup (Optional)

Vorel supports real-time match updates via FRC Nexus webhooks for instant notifications instead of polling:

1. **Configure the webhook token** in your `.env` file:
```bash
NEXUS_WEBHOOK_TOKEN=your_webhook_token_here
```

2. **Register your webhook endpoint** at [frc.nexus/api](https://frc.nexus/api):
- **Webhook URL**: `https://your-domain.com/api/webhook/nexus`
- **Token**: Use the same token you set in `NEXUS_WEBHOOK_TOKEN`
- **Event Type**: Live event status (general) or Match status (team-specific)

3. **Benefits of webhook setup**:
- Instant updates when match status changes (no 5-second polling delay)
- More efficient - only updates when there's actual data changes
- Lower server load and API usage
- Real-time notifications for teams using your instance

4. **Monitoring**:
- View webhook statistics in the admin dashboard at `/admin`
- Check endpoint `/api/webhook-stats` for webhook metrics
- Check endpoint `/api/sse-stats` for active connections

Without webhook setup, the system will continue to work using 5-second polling, which is still very responsive.

## Usage

### Running locally
Expand Down
11 changes: 8 additions & 3 deletions docker-compose-dockploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ services:
- PORT=${Port:-3002}
- Nexus_Api_Key=${Nexus_Api_Key}
- TBA_API_Key=${TBA_API_Key}
- NEXUS_WEBHOOK_TOKEN=${NEXUS_WEBHOOK_TOKEN}
- DB_HOST=mariadb
- DB_PORT=3306
- DB_NAME=vorel
- DB_USER=${DB_USER:-vorel}
- DB_PASSWORD=${DB_PASSWORD}
- GITHUB_CALLBACK_URL=${GITHUB_CALLBACK_URL}
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}
- AUTHORIZED_GITHUB_USERS=${AUTHORIZED_GITHUB_USERS}
depends_on:
- mariadb
networks:
- app-network
- vorel-app-network
- dokploy-network
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:${Port:-3002}/api/health"]
Expand All @@ -42,7 +47,7 @@ services:
volumes:
- mariadb_data:/var/lib/mysql
networks:
- app-network
- vorel-app-network
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 30s
Expand All @@ -63,7 +68,7 @@ volumes:
mariadb_data:

networks:
app-network:
vorel-app-network:
driver: bridge
dokploy-network:
external: true
13 changes: 9 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ services:
- PORT=${Port:-3002}
- Nexus_Api_Key=${Nexus_Api_Key}
- TBA_API_Key=${TBA_API_Key}
- NEXUS_WEBHOOK_TOKEN=${NEXUS_WEBHOOK_TOKEN}
- DB_HOST=mariadb
- DB_PORT=3306
- DB_NAME=vorel
- DB_USER=${DB_USER:-vorel}
- DB_PASSWORD=${DB_PASSWORD}
- GITHUB_CALLBACK_URL=${GITHUB_CALLBACK_URL}
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}
- AUTHORIZED_GITHUB_USERS=${AUTHORIZED_GITHUB_USERS}
depends_on:
- mariadb
networks:
- app-network
- vorel-app-network
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:${Port:-3002}/api/health"]
interval: 30s
Expand All @@ -39,11 +44,11 @@ services:
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
- MYSQL_DATABASE=vorel
- MYSQL_USER=${DB_USER:-vorel}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_PASSWORD=${DB_PASSWORD}
volumes:
- mariadb_data:/var/lib/mysql
networks:
- app-network
- vorel-app-network
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 30s
Expand All @@ -64,5 +69,5 @@ volumes:
mariadb_data:

networks:
app-network:
vorel-app-network:
driver: bridge
Loading