Conversation
…ing in-memory cache
…ter executing refresh request using Redis
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.
This pull request introduces token blacklisting for JWT access and refresh tokens by integrating Redis as a centralized blacklist store. It ensures that tokens can be invalidated immediately upon logout or refresh, enhancing security against token reuse. The implementation includes new configuration, service, and controller logic, as well as necessary dependency and configuration updates.
Token Blacklisting and Security Enhancements:
LogoutServiceto handle blacklisting of access and refresh tokens in Redis, including methods to add tokens to the blacklist and check their status. (src/main/java/com/be08/smart_notes/service/LogoutService.java)BlacklistFilterinSecurityConfigthat checks for blacklisted access tokens on every request and blocks access if the token is invalidated. (src/main/java/com/be08/smart_notes/config/SecurityConfig.java)AuthenticationServiceto:logoutmethod to blacklist the current access token. (src/main/java/com/be08/smart_notes/service/AuthenticationService.java) [1] [2] [3] [4]/logoutendpoint toAuthenticationControllerto allow users to invalidate their current access token. (src/main/java/com/be08/smart_notes/controller/AuthenticationController.java)Redis Integration:
pom.xmlfor storing blacklisted tokens and handling Java 8 date/time serialization. (pom.xml)RedisConfigto configure aRedisTemplatebean for use in the application. (src/main/java/com/be08/smart_notes/config/RedisConfig.java)application.properties. (src/main/resources/application.properties)JWT Improvements:
JwtServiceto include a unique token ID (jti) in every JWT, which is used for blacklist tracking. (src/main/java/com/be08/smart_notes/service/JwtService.java) [1] [2]These changes collectively enable secure, immediate invalidation of JWTs, preventing their use after logout or refresh, and lay the groundwork for robust session management in the application.