mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
SigV4Validator (ElastiCache proxy) and RdsSigV4Validator (RDS proxy, also reused by Redshift) each reimplemented the same ~60-line AWS SigV4 presigned-URL verification algorithm (query parsing, expiry check, secret resolution, canonical request, signing key derivation, signature comparison), flagged as duplicated by CPD. Extracted the shared algorithm into SigV4RequestValidator under core.common.auth; both validators now delegate to it, parameterized only by their genuine differences: the identity query parameter (User vs DBUser), whether that parameter is required to be present at all (RDS always requires DBUser; ElastiCache does not require User), and the exact string each signs as the canonical host header (cluster ID for ElastiCache, host:port for RDS). No behavior change. Public constructors and validate(...) signatures on both SigV4Validator and RdsSigV4Validator are unchanged, since existing unit tests construct them directly with an IamService and reflect on a declared sanitizeForLog method on each class; that method is kept (identically implemented, not delegated) on both wrapper classes specifically so those tests keep working unmodified. All existing SigV4 validator, ElastiCache, RDS, and Redshift tests pass unchanged.