Replace phonenumber with hash for Redis key #39
Merged
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.
This pull request introduces changes to improve error handling and security in the SMS token generation and verification process. The main updates include adding error handling for token generation and verification, and hashing phone numbers before storing them in Redis.
Error Handling Improvements:
src/main/java/foundation/privacybydesign/sms/SMSRestApi.java
: Added error handling for token generation and verification insendSmsCode
andverifySmsCode
methods to return appropriate error responses. [1] [2]Security Enhancements:
src/main/java/foundation/privacybydesign/sms/tokens/RedisTokenRequestRepository.java
: Implemented hashing of phone numbers using SHA-256 before storing, retrieving, and removing them in Redis. AddedCreateHash
method for this purpose. [1] [2] [3] [4]Interface and Method Updates:
src/main/java/foundation/privacybydesign/sms/tokens/TokenManager.java
: Updatedgenerate
andverify
methods to throwException
for better error handling. [1] [2]src/main/java/foundation/privacybydesign/sms/tokens/TokenRequestRepository.java
: Modified interface methods to throwException
to align with changes inTokenManager
.