CROP
ProjectsParts Services

API Endpoints Authentication Audit

Date: 2025-11-13 Status: Phase 1 - Initial Audit Purpose: Classify all API endpoints by authentication requirements

API Endpoints Authentication Audit

Date: 2025-11-13 Status: Phase 1 - Initial Audit Purpose: Classify all API endpoints by authentication requirements


Payment Service

Base URL: /api

Public Endpoints (No Auth Required)

EndpointMethodPurposeStatus
/healthGETHealth check✅ Public
/readyGETReadiness check✅ Public
/webhooks/clerkPOSTClerk webhook receiver✅ Public (Svix verification)
/webhooks/stripePOSTStripe webhook receiver✅ Public (Stripe verification)

Customer Endpoints (Auth Required, Any Role)

EndpointMethodPurposeAuth Status
/api/checkoutPOSTCreate checkout session🔄 TODO: Add clerkMiddleware()
/api/customersGETList customers🔄 TODO: Add auth + ownership check
/api/customers/:idGETGet customer details🔄 TODO: Add auth + ownership check
/api/customers/:idPATCHUpdate customer🔄 TODO: Add auth + ownership check

Admin Endpoints (Admin Role Required)

EndpointMethodPurposeAuth Status
None currently defined---

Recommendation:

  • Add admin endpoints for: refunds, list all customers, delete payments
  • Protect customer routes with ownership checks

Search Service

Base URL: /api

Public Endpoints (No Auth Required)

EndpointMethodPurposeStatus
/health, /ready, /liveGETHealth checks✅ Public
/metricsGETPrometheus metrics✅ Public (consider restricting)
/api/searchGETSearch parts✅ Public
/api/autocompleteGETAutocomplete suggestions✅ Public
/api/filtersGETFilter aggregations✅ Public
/api/parts/:idGETGet single part✅ Public
/api/equipmentGETBrowse equipment models✅ Public
/api/equipment/categoriesGETEquipment categories✅ Public

Admin Endpoints (Admin Role Required)

EndpointMethodPurposeAuth Status
/api/admin/*POST/GET/DELETEAdmin operations✅ Has ADMIN_API_TOKEN + IP whitelist
/api/admin/reindexPOSTTrigger reindex✅ Token protected
/api/admin/debug-queryGETDebug query builder✅ Token protected

Note: Admin endpoints use custom token auth (ADMIN_API_TOKEN), not Clerk. Consider migrating to Clerk for consistency.

Recommendation:

  • Keep search endpoints public (catalog browsing)
  • Consider Clerk auth for admin endpoints for consistency

Catalog Service

Base URL: /api

Public Endpoints (No Auth Required)

EndpointMethodPurposeStatus
/healthGETHealth check✅ Public
/readyGETReadiness check✅ Public
/api/exampleGETExample routes✅ Public
/api/search-integrationGET/POSTSearch integration✅ Public

Customer Endpoints (Auth Required)

EndpointMethodPurposeAuth Status
None currently defined---

Admin Endpoints (Admin Role Required)

EndpointMethodPurposeAuth Status
None currently defined---

Recommendation:

  • Add CRUD endpoints for parts, brands, categories
  • Protect with admin role

User Service

Base URL: /api

Status

⚠️ Not analyzed yet - Need to review routes


Media Service

Base URL: /api

Status

⚠️ Not analyzed yet - Need to review routes


Health Analytics Service

Base URL: /api

Status

⚠️ Not analyzed yet - Need to review routes


Summary Statistics

ServiceTotal EndpointsPublicCustomerAdminTodo
Payment84404
Search118030
Catalog44000
Identity?????
Media?????
Health Analytics?????

Total TODO Items: 4+ endpoints need auth implementation


Implementation Priority

🔴 P0 (Critical - Do Immediately)

  1. Payment Service - Customer Routes
    • Add clerkMiddleware() to /api/checkout, /api/customers/*
    • Add ownership checks (customer can only access own data)
    • Add admin endpoints for refunds

🟡 P1 (High - Do This Week)

  1. Search Service - Admin Migration

    • Migrate admin endpoints from token auth to Clerk
    • Add requireRole('admin') middleware
    • Keep backward compatibility with ADMIN_API_TOKEN temporarily
  2. Catalog Service - CRUD Endpoints

    • Add admin CRUD for parts, brands, categories
    • Protect with requireRole('admin')

🟢 P2 (Medium - Do Next Week)

  1. Identity/Media/Health Services
    • Audit and classify endpoints
    • Add auth where needed

Next Steps

  1. ✅ Complete audit (this document)
  2. 🔄 Create Clerk env vars template
  3. 🔄 Add shared-auth to all services
  4. 🔄 Implement auth in Payment service (P0)
  5. 🔄 Write integration tests
  6. 🔄 Deploy with monitoring

Last Updated: 2025-11-13 Reviewed By: Backend Team

On this page