Skip to content

Conversation

@tafaust
Copy link
Contributor

@tafaust tafaust commented Oct 13, 2025

  • Updated security definitions in Swagger and Go files to replace BearerAuth with JwtAuth.
  • Simplified API key and JWT authentication across various controllers and middleware.
  • Removed unauthorized response handling from API documentation.
  • Enhanced API key management documentation for clarity.
  • Updated frontend SDK to reflect changes in API key and JWT authentication methods.

Warning

Attention: Breaking change with the API Key !
Change header from Authorization: pk_... to X-API-Key: pk_...

Resolves #208

- Updated security definitions in Swagger and Go files to replace BearerAuth with JwtAuth.
- Simplified API key and JWT authentication across various controllers and middleware.
- Removed unauthorized response handling from API documentation.
- Enhanced API key management documentation for clarity.
- Updated frontend SDK to reflect changes in API key and JWT authentication methods.
@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 46.15385% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.90%. Comparing base (0ad9871) to head (e5c5bef).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
apps/server/src/modules/middleware/auth_chain.go 0.00% 13 Missing ⚠️
apps/server/src/modules/api_key/api_key.service.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #210      +/-   ##
==========================================
+ Coverage   18.61%   19.90%   +1.29%     
==========================================
  Files         181      181              
  Lines       18826    18829       +3     
==========================================
+ Hits         3504     3748     +244     
+ Misses      15161    14897     -264     
- Partials      161      184      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

… headers

- Changed log level from Warn to Debug for missing authentication headers in AllAuth method to reduce log noise.
- Minor formatting adjustment in the code for improved readability.
- Updated log level from Info to Debug for API key and JWT authentication routing to reduce log verbosity.
- Changed log level from Debug to Warn for missing authentication headers to highlight critical issues more effectively.
- Updated error messages in the ValidateKey method to use lowercase "invalid API key" for consistency.
- Changed the context parameter in the ValidateKey method call from the gin context to the request context for improved consistency and reliability in API key validation.
…ware

- Introduced unit tests for the API key service, covering key creation, validation, expiration handling, and usage limits.
- Added middleware tests to ensure proper authentication flow and error handling for missing or invalid API keys.
- Implemented a mock service for testing middleware interactions, enhancing test coverage and reliability.
- Introduced a new integration test suite for the API key service, covering key creation, validation, expiration handling, and usage limits.
- Implemented tests for middleware interactions with real HTTP requests to ensure proper authentication flow.
- Enhanced test coverage by validating key usage count updates and handling of expired keys.
@tafaust
Copy link
Contributor Author

tafaust commented Oct 13, 2025

I added some fixes, unit tests and gave integration tests a stab. Please let me know if I should revert something.

@0xfurai
Copy link
Owner

0xfurai commented Oct 14, 2025

LGTM!

@0xfurai 0xfurai merged commit 4b3adfa into 0xfurai:main Oct 14, 2025
9 checks passed
tafaust added a commit to tafaust/peekaping that referenced this pull request Oct 14, 2025
* feat: refactor swagger API authentication

- Updated security definitions in Swagger and Go files to replace BearerAuth with JwtAuth.
- Simplified API key and JWT authentication across various controllers and middleware.
- Removed unauthorized response handling from API documentation.
- Enhanced API key management documentation for clarity.
- Updated frontend SDK to reflect changes in API key and JWT authentication methods.

* refactor(auth_chain): update logging level for missing authentication headers

- Changed log level from Warn to Debug for missing authentication headers in AllAuth method to reduce log noise.
- Minor formatting adjustment in the code for improved readability.

* refactor(auth_chain): change logging levels for authentication routing

- Updated log level from Info to Debug for API key and JWT authentication routing to reduce log verbosity.
- Changed log level from Debug to Warn for missing authentication headers to highlight critical issues more effectively.

* fix(api_key): standardize error messages for invalid API keys

- Updated error messages in the ValidateKey method to use lowercase "invalid API key" for consistency.

* fix(api_key): update context usage in API key validation

- Changed the context parameter in the ValidateKey method call from the gin context to the request context for improved consistency and reliability in API key validation.

* feat(api_key): add comprehensive tests for API key service and middleware

- Introduced unit tests for the API key service, covering key creation, validation, expiration handling, and usage limits.
- Added middleware tests to ensure proper authentication flow and error handling for missing or invalid API keys.
- Implemented a mock service for testing middleware interactions, enhancing test coverage and reliability.

* feat(api_key): add integration tests for API key service functionality

- Introduced a new integration test suite for the API key service, covering key creation, validation, expiration handling, and usage limits.
- Implemented tests for middleware interactions with real HTTP requests to ensure proper authentication flow.
- Enhanced test coverage by validating key usage count updates and handling of expired keys.
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.

[Chore]: Move Api Key into its own http header

2 participants