Finish functionality to generate API key and authenticate with it#3
Finish functionality to generate API key and authenticate with it#3
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements complete API key functionality, enabling users to generate API keys through the frontend and authenticate with them on the backend. The implementation replaces the previous mock/placeholder functionality with a full working system.
- Replaces mock API key generation with real backend integration
- Adds database support for storing API keys with unique constraints
- Implements API key authentication filter for secure access
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/pages/Profile.tsx | Replaces mock API key generation with real backend API call |
| backend/src/main/resources/db/migration/V3__add_api_key_column.sql | Adds API key column and unique index to user_account table |
| backend/src/main/java/net/hackyourfuture/coursehub/web/model/ApiKeyResponse.java | Creates response model for API key generation endpoint |
| backend/src/main/java/net/hackyourfuture/coursehub/web/UserAuthenticationController.java | Adds POST endpoint for generating API keys |
| backend/src/main/java/net/hackyourfuture/coursehub/service/UserAuthenticationService.java | Implements secure API key generation and user lookup by API key |
| backend/src/main/java/net/hackyourfuture/coursehub/security/ApiKeyAuthenticationFilter.java | Creates authentication filter for API key-based requests |
| backend/src/main/java/net/hackyourfuture/coursehub/repository/UserAccountRepository.java | Adds database methods for API key storage and retrieval |
| backend/src/main/java/net/hackyourfuture/coursehub/data/UserAccountEntity.java | Updates entity to include API key field |
| backend/src/main/java/net/hackyourfuture/coursehub/SecurityConfig.java | Integrates API key authentication filter into security chain |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
backend/src/main/java/net/hackyourfuture/coursehub/web/UserAuthenticationController.java
Outdated
Show resolved
Hide resolved
backend/src/main/java/net/hackyourfuture/coursehub/security/ApiKeyAuthenticationFilter.java
Show resolved
Hide resolved
11b0dce to
e3aa5e8
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
backend/src/main/java/net/hackyourfuture/coursehub/security/ApiKeyAuthenticationFilter.java
Show resolved
Hide resolved
backend/src/main/java/net/hackyourfuture/coursehub/service/UserAuthenticationService.java
Outdated
Show resolved
Hide resolved
| public class ApiKeyAuthenticationFilter extends OncePerRequestFilter { | ||
|
|
||
| private final UserAuthenticationService userAuthenticationService; | ||
| private static final String API_KEY_HEADER = "X-API-Key"; |
There was a problem hiding this comment.
Why not use standard Authorization: <api-key> header?
No description provided.