Skip to content

Add Firebase Storage rules for GPX file uploads - #74

Open
aleexwong wants to merge 5 commits into
mainfrom
claude/busy-dijkstra-6lgdvq
Open

Add Firebase Storage rules for GPX file uploads#74
aleexwong wants to merge 5 commits into
mainfrom
claude/busy-dijkstra-6lgdvq

Conversation

@aleexwong

Copy link
Copy Markdown
Owner

Summary

Configure Firebase Storage security rules to enable authenticated GPX file uploads for the elevation analysis feature while maintaining public read access and enforcing file size/type constraints.

Changes

  • storage.rules (new file): Added Firebase Storage security rules with:

    • Public read access to /gpx_files/ directory
    • Authenticated write access restricted to files prefixed with user's UID
    • 10 MB file size limit
    • Content-type validation (GPX and XML formats only)
    • Default deny-all rule for all other paths
  • firebase.json: Updated to include storage rules configuration alongside existing Firestore rules

  • .gitignore: Added Firebase CLI debug logs and .firebase/ directory to prevent accidental commits

Implementation Details

The storage rules follow the principle of least privilege:

  • Users can only upload files to paths matching their own UID (e.g., gpx_files/user123_filename.gpx)
  • File uploads are validated at the storage layer for size and content type
  • All other storage paths are explicitly denied by default
  • Public read access allows the elevation analysis feature to retrieve and display user-uploaded GPX files

This enables the Course Elevation Analysis feature to securely handle GPX file uploads from authenticated users.

https://claude.ai/code/session_019d81oQrnrfShaqUsxcPTBj

claude added 2 commits June 27, 2026 16:58
Enforces that only the file owner can upload GPX files (filename must be
prefixed with the authenticated user's UID), caps uploads at 10 MB, and
restricts content types to GPX/XML. Denies all other storage paths by
default. Adds storage.rules to source control so it deploys alongside
firestore.rules via the Firebase CLI.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019d81oQrnrfShaqUsxcPTBj
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
trainpace Ready Ready Preview, Comment Jun 30, 2026 7:57am

@netlify

netlify Bot commented Jun 27, 2026

Copy link
Copy Markdown

Deploy Preview for trainpace ready!

Name Link
🔨 Latest commit c9d2a28
🔍 Latest deploy log https://app.netlify.com/projects/trainpace/deploys/6a4376af2700bc0008136f8c
😎 Deploy Preview https://deploy-preview-74--trainpace.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 54
Accessibility: 89
Best Practices: 100
SEO: 100
PWA: 60
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@codacy-production

codacy-production Bot commented Jun 27, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 70 high · 21 medium · 3 minor

Alerts:
⚠ 94 issues (≤ 0 issues of at least minor severity)

Results:
94 new issues

Category Results
BestPractice 3 medium
1 minor
ErrorProne 10 medium
58 high
Security 12 high
CodeStyle 2 minor
Complexity 8 medium

View in Codacy

🟢 Metrics 182 complexity · -2 duplication

Metric Results
Complexity 182
Duplication -2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

aleexwong and others added 2 commits June 28, 2026 00:12
Adds /simulate: pick a course and goal time, get a Minetti GAP-based
even-effort pacing plan adjusted for elevation. Includes 15 major
marathons, full/half toggle, km/mi units, shareable URL state, VDOT
feasibility check, training implications panel, graded elevation chart,
and CTAs wired to Fuel Planner (pre-filled with simulated finish time)
and Pace Calculator.

Also adds blog posts driving traffic to the feature and wires the
simulator into race SEO landing pages, VDOT calculator, footer, and nav.

Bug fixes from code review: displayPace "X:60 /mi" rollover, effort pace
stat ignoring units toggle, sub-1h regex corrupting realistic-goal button,
misleading "flat marathon" label in half mode, gapFactor math deduplicated
via shared helper, paceSecPerKm checkpoint fallback with float tolerance,
empty-segments guard, activePoints.length guard, inline goal error message.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add storage.rules (gpx_files: public read, owner-prefixed write) and
  register a storage target in firebase.json so `deploy --only storage` works
- Add .firebaserc aliases: production -> trainpace-prod, staging -> trainpace-staging
  for project-level isolation of Vercel preview/staging data from prod
- Document VITE_FIREBASE_* vars + env scoping in .env.example
- Document the prod/staging environment setup in CLAUDE.md

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- storage.rules: split allow write into create/update + delete to avoid
  null-deref on request.resource during DELETE operations
- firestore.rules: restrict gpx_uploads list to owner; restore createdBy
  ownership check on elevation_analysis_cache update/delete
- firestore.indexes.json: add composite indexes for gpx_uploads duplicate
  check (userId+fileHash+deleted) and rate limit queries (userId+uploadedAt)
- firebase.json: wire up indexes file alongside existing rules config
- GpxUploader: wrap checkRateLimits in useCallback with correct deps;
  make handleDuplicateAction async and clear modal state before awaiting
  upload; add missing fileHash/deleted/contentValidated to Method 3 addDoc
- AuthContext: guard posthog.identify against repeated calls on page
  refresh; wrap posthog calls in try/catch so ad-blocker exceptions don't
  stall auth state
- useTrainingPlans: add stale-response guard for rapid userId changes;
  add error state on removePlan failure
- useGpxAnalysis: preserve raceName through cache round-trip
- types.ts: add routeName to StaticRouteData interface
- Settings.tsx: remove user_training_goals from hardDeleteCollections to
  prevent account deletion abort on docId-keyed Firestore rule

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019d81oQrnrfShaqUsxcPTBj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants