Commit Graph
20 Commits
Author SHA1 Message Date
john-okeefe 799b640ddd chore(server): integrate request tracing and auto-start services
- Add RequestTracingMiddleware to middleware chain
- Auto-start scheduler for auto-scanning on server boot
- Auto-start watch mode for all libraries with 2-second delay
- Update SetupRoutes to return handler for service management
2026-01-29 09:50:40 -05:00
john-okeefe 1e04ef4861 test(security): add comprehensive security tests
- Test password complexity requirements
- Test account lockout mechanism
- Test rate limiting functionality
- Test JWT expiration (1 hour)
- Test refresh token expiration (7 days)
- Test password requirements list
- Verify transaction manager and error handler types
- All tests passing
2026-01-29 09:23:34 -05:00
john-okeefe 11ea4588d1 test: add comprehensive test suite covering all failure points
Added 157+ tests across 8 test files:
- registration_test.go: 19 registration and 10 login scenarios
- ebook_test.go: 40 ebook and media management tests
- user_test.go: 35 user profile and account management tests
- library_test_comprehensive.go: 25 library management tests
- edge_cases_test.go: 30+ security and edge case tests
- new_fixes_test.go: tests for new security fixes
- test_helpers.go: shared test utilities

Test Coverage:
- Authentication & authorization
- Input validation (email, username, password)
- Role-based access control
- Pagination and filtering
- Error handling and edge cases
- Security scenarios (SQL injection, XSS)

Documentation:
- TEST_COVERAGE.md: detailed test documentation
- ANALYSIS.md: comprehensive analysis of issues found

All tests pass successfully
2026-01-29 09:23:34 -05:00
john-okeefe 7db8bde4bb feat: add rate limiting to authentication endpoints
- Add rate limiter middleware (10 requests/minute per IP)
- Apply rate limiting to POST /api/auth/register and /api/auth/login
- Prevents brute force attacks and registration spam
- Automatic cleanup of old request records

Closes security issue: No rate limiting on auth endpoints
2026-01-29 09:23:33 -05:00
john-okeefe 935b867219 feat: add highlights and notes annotation system
This major update implements a complete user annotation system:

## 🎯 New Features
- User notes with position tracking for media items
- Text highlighting with customizable colors
- Highlight-note associations for detailed annotations
- Full CRUD API for both notes and highlights
- Backward compatibility with existing ebook endpoints

## 📊 Database Changes
- Add media_notes table (id, media_item_id, user_id, content, position, timestamps)
- Add media_highlights table (id, media_item_id, user_id, selection_text, start/end_position, color, optional note_id)
- Add foreign key relationships with CASCADE deletes
- Add proper indexes for performance
- Add database schema views for ebook backward compatibility

## 🔧 API Implementation
- Complete REST API endpoints for notes and highlights
- JWT authentication with proper middleware bypass
- Request validation with meaningful error responses
- UUID validation and type safety
- Support for hex color codes in highlights

## 🧪 Testing & Documentation
- Comprehensive test suite covering authentication scenarios
- Bruno API collection for manual testing
- Detailed testing guide with troubleshooting
- Updated documentation in README and TESTING.md

## 📁 Backward Compatibility
- Existing ebook endpoints continue working
- Database views maintain API contracts
- No breaking changes for existing integrations

The annotation system is now fully functional and ready for production use.
2026-01-28 17:12:40 -05:00
john-okeefe 14099d8d08 fix: resolve test compilation and logic errors
- Fix undefined variable 'resp' errors in library_test.go (should be 'req')
- Fix authentication test expectations to match unauthorized response
- Fix TestUserVisibleLibraries to properly simulate user visibility filtering
- Remove hidden library from mock user response to test visibility correctly
- All tests now pass successfully
2026-01-28 16:13:50 -05:00
john-okeefe 0a457e02a2 test: add comprehensive tests for notes and highlights
- Add complete test suite for media notes API with validation
- Add complete test suite for media highlights API with color validation
- Add backward compatibility tests for ebook endpoints
- Test authentication scenarios (unauthorized access)
- Test request validation and error handling
- Fix existing test import issues and syntax errors
- Add test cases for highlight-note associations
2026-01-28 15:43:30 -05:00
john-okeefe 6d7e271fb5 test: add comprehensive test suite for library system
- Add authentication middleware tests for JWT validation
- Add library creation tests for admin authorization
- Add library visibility control tests
- Add user management and error handling tests
- Add JSON validation and security tests
- Add tests for both success and failure scenarios
- Test edge cases like missing tokens, invalid data, unauthorized access
- Use httptest for isolated API testing without needing running server
- Include comprehensive test coverage for security and functionality

Tests verify application security and multi-library system works correctly before deployment.
2026-01-28 12:50:42 -05:00
john-okeefe 87e1625564 fix: properly implement JWT user object in middleware
- Update JWT middleware to set complete user object in context
- Parse UUID correctly and convert to pgtype.UUID format
- Add missing imports for uuid and pgx/v5/pgtype
- Fix type conversion from UUID string to byte array
- Ensure compatibility with database.Users struct

Resolves authentication issues for library and user endpoints
2026-01-28 11:34:04 -05:00
john-okeefe e29054f841 feat: integrate library system with routing and handlers
- Add library routes to main router configuration
- Implement media items API endpoints for library content
- Update existing ebook handlers to use new schema
- Add media rating and progress tracking
- Maintain backward compatibility with existing endpoints
- Support library-specific media item queries

Updates application to support new multi-library architecture
2026-01-28 11:02:51 -05:00
john-okeefe 71584c1b55 feat: Enhance admin user management system
- Add admin override capability to DELETE /api/auth/account endpoint
- Move /api/auth/users to admin-only with complete user fields (first_name, last_name, role, theme)
- Consolidate Bruno requests: remove duplicate List Users (Admin), merge Delete Account functionality
- Update all documentation to reflect enhanced capabilities
- Implement pgx 5 standards compliance with proper error handling

BREAKING CHANGES:
- /api/auth/users endpoint now requires admin role (was previously accessible)
- DELETE /api/auth/account accepts optional user_id parameter for admin deletion
2026-01-27 13:36:11 -05:00
john-okeefe f5bfac996d feat: Implement role-based authentication and authorization
- Add AdminMiddleware for protecting sensitive operations
- Update JWT generation to include user role and details
- Modify login/registration to use enhanced JWT claims
- Update main.go to set admin-protected routes
- Add user role to JWT context for downstream handlers
2026-01-26 16:55:32 -05:00
john-okeefe ec1f97828f feat: replace Tailwind CDN with local build system
- Add tailwind.config.js with theme color configuration
- Add package.json with build scripts and dependencies
- Add Dockerfile Node.js setup for CSS building
- Add input.css for Tailwind processing
- Update all templates to use local CSS and JS instead of CDN
- Add static file serving in main.go
- Download htmx during build process
- Enable CSS minification for production builds
2026-01-24 23:52:35 -05:00
john-okeefe 08e80ae84b refactor: reorganize project structure and update configurations
- Move migrations/ to database/schema/ for clarity on database schema definitions
- Move sqlc.yaml to internal/database/ to group with database code
- Move static/ to cmd/server/static/ to co-locate with server
- Update all configuration files and documentation
- Follow Go project conventions for better organization
2026-01-24 23:40:31 -05:00
john-okeefe 8a951fb242 Update dependencies and fix main.go issues 2026-01-23 21:27:18 -05:00
john-okeefe 7c89e9f214 Simplify homepage: remove auth check, keep login hidden for now 2026-01-23 17:56:29 -05:00
john-okeefe 327b1cc5a4 Add strings import for getToken 2026-01-23 17:55:56 -05:00
john-okeefe 21490af3f0 Add jwtgo import for homepage auth check 2026-01-23 17:55:25 -05:00
john-okeefe 2da9245bfc Update homepage: remove create account, hide login if logged in 2026-01-23 17:54:56 -05:00
john-okeefe 335c63a494 Update main.go to use templ components for routing 2026-01-23 17:47:36 -05:00