Repository navigation
Add AES-256 encryption for Redis cache values - #53
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove explicit encryption-salt config property. The salt is now derived deterministically from the cache name via SHA-256 truncated to 16 bytes. This simplifies config to just encryption-password. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use encryption.enabled and encryption.secret instead of flat encryption-secret. This uses a nested @ConfigurationProperties inner class for cleaner YAML structure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add input validation in CacheValueEncryptor.decrypt() for corrupted/truncated data - Catch decryption failures in RedisCache.decryptValue() and treat as cache miss (enables graceful key rotation) - Clear PBEKeySpec password after key derivation - Remove unused lib-crypto dependency from build.gradle Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ptor Add CryptoHelper.deriveKey(password, salt) static method for PBKDF2 key derivation. CacheValueEncryptor now delegates to it instead of duplicating the logic. Restores lib-crypto dependency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add static encrypt/decrypt methods to CryptoHelper for pre-derived keys - Refactor CryptoHelper instance methods to delegate to deriveKey (fixes missing clearPassword) - Simplify CacheValueEncryptor to delegate to CryptoHelper + Sealed (removes duplicated AES logic) - Add bounds check in Sealed.deserialize for null/short input - Fix decryptValue to return empty byte[] instead of null on failure (prevents NPE in serializer) - Fix cipher string casing inconsistency (PKCS5PADDING → PKCS5Padding) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Summary of changeslib-crypto: Groovy → Java conversionAll 7 source files converted to Java, keeping the existing Groovy/Spock tests unchanged:
micronaut-cache-redis: per-cache value encryption
Configredis:
caches:
my-cache:
encryption:
enabled: true
secret: "my-passphrase" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
micronaut-cache-redisCacheValueEncryptordelegates toCryptoHelperstatic methods — no crypto code duplicationEncryption design
encryption.enabled: true+encryption.secretin cache config@Cacheable,SyncCache,AsyncCacheunchanged)Test plan
CacheValueEncryptor(roundtrip, random IV, wrong password, different cache names)./gradlew :lib-crypto:test :micronaut-cache-redis:testall green🤖 Generated with Claude Code