Feature/min io#10
Conversation
- Implement X-API-KEY header validation for /api/v1/sources endpoints - Add proper error responses for missing/invalid API keys - Support configurable API key via application properties - Secure admin APIs while keeping MCP APIs public
- Configure MinIO client bean with endpoint and credentials - Support configurable properties via application.yml - Enable file storage operations for document management
- Add ApiKeyAuthenticationFilter to Spring Security filter chain - Configure protected endpoints for admin APIs (/api/v1/sources) - Keep MCP APIs public while securing admin operations - Enable X-API-KEY header validation for document management
- Add SourceDocumentDto for document list API response - Add SourceUploadResponse for file upload API response
- Add FileStorageService for MinIO file operations - Add SourceDocumentService for document lifecycle management - Implement upload, retrieval, resync, and deletion operations - Support asynchronous document processing pipeline
- Add DocsSourceController interface with Swagger documentation - Add SourceController implementation for document management - Implement upload, list, resync, and delete endpoints - Support /api/v1/sources REST API with proper error handling
- Add error response factory methods for ErrorCode enum integration - Support both custom error messages and predefined error code - Improve error handling consistency across APIs
- Define error codes for authentication, document, file storage operations - Add HTTP status mapping for consistent error responses - Support categorized error codes (COMMON, AUTH, DOC, CTX, FILE, INFRA)
There was a problem hiding this comment.
Pull Request Overview
Implements a comprehensive document management system with MinIO object storage integration for the OpenContext project. The PR adds REST APIs for file upload, retrieval, re-processing, and deletion with X-API-KEY authentication system for admin operations, along with a complete document ingestion pipeline foundation.
- MinIO integration for object storage with automatic bucket management
- API Key authentication system using Spring Security for admin endpoints
- Complete document ingestion pipeline with async processing support
Reviewed Changes
Copilot reviewed 42 out of 44 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
mcp-adapter/.gitignore |
Adds Node.js project gitignore configuration |
docker-compose.yml |
Adds platform architecture specification for containers |
core/build.gradle |
Updates dependencies and adds MinIO, LangChain4j, QueryDSL support |
| Database migration files | Creates PostgreSQL schema for document and chunk storage |
| Entity classes | Implements JPA entities for source documents and document chunks |
| Service layer | Implements document management and file storage services |
| Controller layer | Provides REST API endpoints with comprehensive Swagger documentation |
| Configuration classes | Sets up MinIO, security, async processing, and JPA auditing |
| Test files | Adds comprehensive unit and integration tests |
| <<<<<<< HEAD | ||
| @rem SPDX-License-Identifier: Apache-2.0 | ||
| @rem | ||
| ======= | ||
| @rem SPDX-License-Identifier: Apache-2.0 | ||
| @rem |
There was a problem hiding this comment.
The file contains unresolved merge conflicts. The merge conflict markers (<<<<<<< HEAD, =======, >>>>>>> 2b49148) need to be resolved before merging.
| <<<<<<< HEAD | |
| @rem SPDX-License-Identifier: Apache-2.0 | |
| @rem | |
| ======= | |
| @rem SPDX-License-Identifier: Apache-2.0 | |
| @rem | |
| @rem SPDX-License-Identifier: Apache-2.0 | |
| @rem |
| <<<<<<< HEAD | ||
| echo. 1>&2 | ||
| echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 | ||
| echo. 1>&2 | ||
| echo Please set the JAVA_HOME variable in your environment to match the 1>&2 | ||
| echo location of your Java installation. 1>&2 | ||
| ======= | ||
| echo. | ||
| echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
| echo. | ||
| echo Please set the JAVA_HOME variable in your environment to match the | ||
| echo location of your Java installation. | ||
| >>>>>>> 2b49148 (build: regenerate gradle wrapper for consistent build environment) |
There was a problem hiding this comment.
Additional merge conflict marker found. All merge conflicts throughout the file need to be resolved.
| <<<<<<< HEAD | |
| echo. 1>&2 | |
| echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 | |
| echo. 1>&2 | |
| echo Please set the JAVA_HOME variable in your environment to match the 1>&2 | |
| echo location of your Java installation. 1>&2 | |
| ======= | |
| echo. | |
| echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | |
| echo. | |
| echo Please set the JAVA_HOME variable in your environment to match the | |
| echo location of your Java installation. | |
| >>>>>>> 2b49148 (build: regenerate gradle wrapper for consistent build environment) | |
| echo. 1>&2 | |
| echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 | |
| echo. 1>&2 | |
| echo Please set the JAVA_HOME variable in your environment to match the 1>&2 | |
| echo location of your Java installation. 1>&2 |
| if (file.getSize() > 100 * 1024 * 1024) { // 100MB | ||
| throw new BusinessException(ErrorCode.PAYLOAD_TOO_LARGE, | ||
| "File size exceeds maximum limit of 100MB"); |
There was a problem hiding this comment.
The file size limit (100MB) is hardcoded. Consider making this configurable through application properties to allow different limits in different environments.
| if (file.getSize() > 100 * 1024 * 1024) { // 100MB | |
| throw new BusinessException(ErrorCode.PAYLOAD_TOO_LARGE, | |
| "File size exceeds maximum limit of 100MB"); | |
| if (file.getSize() > maxFileSize) { | |
| throw new BusinessException(ErrorCode.PAYLOAD_TOO_LARGE, | |
| String.format("File size exceeds maximum limit of %.2fMB", maxFileSize / (1024.0 * 1024.0))); |
| @Value("${opencontext.api.key:dev-api-key-123}") | ||
| private String validApiKey; | ||
|
|
||
| // Endpoints that require API Key authentication |
There was a problem hiding this comment.
The default API key 'dev-api-key-123' is weak and predictable. Consider using a stronger default or requiring the API key to be explicitly configured in production environments.
| @Value("${opencontext.api.key:dev-api-key-123}") | |
| private String validApiKey; | |
| // Endpoints that require API Key authentication | |
| @Value("${opencontext.api.key}") | |
| private String validApiKey; | |
| // Endpoints that require API Key authentication | |
| // Ensure the API key is set and not weak | |
| @jakarta.annotation.PostConstruct | |
| private void validateApiKey() { | |
| if (!StringUtils.hasText(validApiKey) || "dev-api-key-123".equals(validApiKey)) { | |
| throw new IllegalStateException("API key must be explicitly configured and not use a default/weak value."); | |
| } | |
| } |
Summary of Changes
Implemented a comprehensive document management system with MinIO object storage integration. Added REST APIs for file upload, retrieval, re-processing, and deletion with X-API-KEY authentication system for admin operations.
Type of Change
Related Issues
Closes #issue-number
Testing Instructions
./gradlew bootRun/api/v1/sources/upload- File upload (requires X-API-KEY: dev-api-key-123 header)/api/v1/sources- List all documents with pagination/api/v1/sources/{id}/resync- Re-process document/api/v1/sources/{id}- Delete documentScreenshots (if applicable)
Checklist
Additional Notes
Key Implementation Features:
Configuration Requirements:
Files Added/Modified:
MinIOConfig.java- MinIO client configurationApiKeyAuthenticationFilter.java- API key authentication filterSecurityConfig.java- Spring Security integrationSourceController.java&DocsSourceController.java- REST API controllersFileStorageService.java&SourceDocumentService.java- Business logic servicesSourceDocumentDto.java&SourceUploadResponse.java- API response DTOsCommonResponse.java&ErrorCode.java- Error handling infrastructure