Commit Graph

18 Commits

Author SHA1 Message Date
Cameron da16fddce3 Address path traversal and other security fixes 2026-04-10 14:58:57 -04:00
Cameron 2c52cffd65 Implement critical security improvements for authentication
This commit addresses several security vulnerabilities in the authentication
and authorization system:

1. JWT Encoding Panic Fix (Critical)
   - Replace .unwrap() with proper error handling in JWT token generation
   - Prevents server crashes from encoding failures
   - Returns HTTP 500 with error logging instead of panicking

2. Rate Limiting for Login Endpoint (Critical)
   - Add actix-governor dependency (v0.5)
   - Configure rate limiter: 2 requests/sec with burst of 5
   - Protects against brute-force authentication attacks

3. Strengthen Password Requirements
   - Minimum length increased from 6 to 12 characters
   - Require uppercase, lowercase, numeric, and special characters
   - Add comprehensive validation with clear error messages

4. Fix Token Parsing Vulnerability
   - Replace unsafe split().last().unwrap_or() pattern
   - Use strip_prefix() for proper Bearer token validation
   - Return InvalidToken error for malformed Authorization headers

5. Improve Authentication Logging
   - Sanitize error messages to avoid leaking user existence
   - Change from "User not found or incorrect password" to "Failed login attempt"

All changes tested and verified with existing test suite (65/65 tests passing).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-26 23:53:54 -05:00
Cameron df94010d21 Fix tests and improve memories date error log 2025-12-19 14:20:51 -05:00
Cameron 273b877e16 Update to Rust 2024 edition
Formatted code.
2025-09-01 13:36:27 -04:00
Cameron Cordes 7863990c68 Run clippy 2023-03-25 20:59:32 -04:00
Cameron Cordes de4041bd17 Refactor tags services and added tests
Implemented some functionality which will allow the service
configuration of the app to be split among the features for readability
and testability.
2023-03-19 15:05:20 -04:00
Cameron Cordes fbcfc68e01 Fix tests 2023-03-19 12:29:33 -04:00
Cameron Cordes 68bfcbf85f Update and Migrate Diesel to 2.0
Almost have tag support working, still figuring out how to get photo
tags.
2023-03-18 14:43:41 -04:00
Cameron Cordes 4d9b7c91a1 Improve testability and remove boxing
Core Repos/ImageApi/pipeline/pr-master There was a failure building this commit
Leverage generics to remove the extra heap allocation for the response
handlers using Dao's. Also moved some of the environment variables to
app state to allow for easier testing.
2022-03-16 20:51:37 -04:00
Cameron Cordes 50e973da1f Cleanup unused imports
Core Repos/ImageApi/pipeline/pr-master This commit looks good
2022-03-01 21:16:04 -05:00
Cameron Cordes 69fe307516 Update to Actix 4
Core Repos/ImageApi/pipeline/pr-master There was a failure building this commit
2022-03-01 20:38:41 -05:00
Cameron Cordes 2c50b4ae2f Add anyhow, Improve Auth token code
Moved test helper code to its own module.
2021-10-07 20:32:36 -04:00
Cameron Cordes 3c02bcc8fb Check upload name to make sure its an image or video
Core Repos/ImageApi/pipeline/head This commit looks good
The upload code should be additionally refactored to probably do a more
comprehensive check of if the file is an image or video.
2021-03-07 22:00:12 -05:00
Cameron Cordes 3611f46004 Fix test name and simplify helper 2021-03-04 16:37:19 -05:00
Cameron Cordes e5ad88abd6 Create UserDao and unit tests for login 2021-02-26 08:48:33 -05:00
Cameron Cordes 64bfb58734 Log when unknown user tries to log in 2021-02-25 17:42:16 -05:00
Cameron Cordes f9983240df Use log crate for logging instead of println
Core Repos/ImageApi/pipeline/head This commit looks good
Core Repos/ImageApi/pipeline/pr-master This commit looks good
2021-02-24 21:26:11 -05:00
Cameron Cordes 8b5ba9d48c Move auth related methods to their own module 2021-02-18 20:31:29 -05:00