Skip to content

add api key auth for /api/v1 routes - #35

Merged
vigneshrajsb merged 5 commits into
mainfrom
api-key-auth
Aug 20, 2025
Merged

add api key auth for /api/v1 routes#35
vigneshrajsb merged 5 commits into
mainfrom
api-key-auth

Conversation

@vigneshrajsb

@vigneshrajsb vigneshrajsb commented Aug 16, 2025

Copy link
Copy Markdown
Contributor
  • API key based authentication Authorization: Bearer API_KEY
  • simple auth service with options to expand on user specific keys and scopes later
  • configurable rate limits
  • update open api specs
  • add auth to all non public endpoints

add security scheme to docs
@vigneshrajsb
vigneshrajsb requested a review from Copilot August 16, 2025 04:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds API key authentication for all /api/v1 routes to secure the public API endpoints. The implementation includes a complete authentication system with key generation, validation, rate limiting, and administrative management capabilities.

Key changes include:

  • Implementation of API key authentication with Bearer token format using lfc_ prefixed keys
  • Addition of rate limiting and security validation middleware
  • Creation of admin endpoints for API key management (create, list, update, revoke)

Reviewed Changes

Copilot reviewed 38 out of 39 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
swaggerSpec.ts Added security scheme definition for API key authentication in OpenAPI documentation
src/server/services/auth.ts New authentication service with API key creation, validation, and management capabilities
src/server/models/ApiKey.ts New database model for storing API key metadata with proper column mapping
src/server/lib/auth/validate.ts Authentication validation middleware for API routes with rate limiting checks
src/server/lib/auth/rateLimiter.ts Redis-based rate limiting implementation using fixed window algorithm
src/server/lib/auth/keyGenerator.ts Secure API key generation and validation utilities using bcrypt
src/server/db/migrations/003_add_api_keys.ts Database migration to create api_keys table with proper indexes
src/pages/v1/docs.tsx Updated API documentation to include security scheme definitions
src/pages/api/v1/**/*.ts Added authentication validation to all v1 API endpoints
src/pages/api/v1/admin/api-keys/*.ts New admin endpoints for API key CRUD operations
src/middleware.ts Edge middleware for basic API key format validation before route processing
package.json Added bcryptjs dependency for secure password hashing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread src/server/lib/auth/validate.ts Outdated
Comment thread src/server/lib/auth/rateLimiter.ts
Comment thread src/server/services/auth.ts
Comment thread src/server/lib/auth/keyGenerator.ts Outdated
Comment thread src/middleware.ts Outdated
@vigneshrajsb
vigneshrajsb marked this pull request as ready for review August 20, 2025 21:36
@vigneshrajsb
vigneshrajsb requested a review from a team as a code owner August 20, 2025 21:36
@vigneshrajsb
vigneshrajsb merged commit cf092f7 into main Aug 20, 2025
6 of 9 checks passed
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.

3 participants