-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jwt api implementation #110
Open
indraniBan
wants to merge
7
commits into
develop
Choose a base branch
from
jwt-api
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
37b0893
jwt api implementation
70b904b
Formatting and dependency upgrade
13d90da
changes by coderabbit comments
9484afb
fixed issues
eb2f985
use fetch from redis concept
d57b1ca
user fetch concept modify
d04dd99
Merge branch 'develop' into jwt-api
indraniBan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,9 @@ prescription=TMPrescription SMS | |
|
||
### Redis IP | ||
spring.redis.host=localhost | ||
[email protected]_SECRET_KEY@ | ||
|
||
|
||
#ELK logging file name | ||
[email protected]_API_LOGGING_FILE_NAME@ | ||
[email protected]_API_LOGGING_FILE_NAME@ | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,7 @@ prescription=TMPrescription SMS | |
|
||
### Redis IP | ||
spring.redis.host=localhost | ||
jwt.secret= | ||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,7 @@ prescription=TMPrescription SMS | |
|
||
### Redis IP | ||
spring.redis.host=localhost | ||
jwt.secret= | ||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,7 @@ prescription=TMPrescription SMS | |
|
||
### Redis IP | ||
spring.redis.host=localhost | ||
jwt.secret= | ||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ prescription=TMPrescription SMS | |
|
||
### Redis IP | ||
spring.redis.host=localhost | ||
jwt.secret= | ||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ prescription=TMPrescription SMS | |
|
||
### Redis IP | ||
spring.redis.host=localhost | ||
jwt.secret= | ||
|
||
|
||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.iemr.hwc.config; | ||
|
||
import org.springframework.cache.annotation.EnableCaching; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
import org.springframework.session.data.redis.config.ConfigureRedisAction; | ||
|
||
import com.iemr.hwc.data.login.Users; | ||
|
||
@Configuration | ||
@EnableCaching | ||
public class RedisConfig { | ||
|
||
@Bean | ||
public ConfigureRedisAction configureRedisAction() { | ||
return ConfigureRedisAction.NO_OP; | ||
} | ||
|
||
@Bean | ||
public RedisTemplate<String, Users> redisTemplate(RedisConnectionFactory factory) { | ||
RedisTemplate<String, Users> template = new RedisTemplate<>(); | ||
template.setConnectionFactory(factory); | ||
|
||
// Use StringRedisSerializer for keys (userId) | ||
template.setKeySerializer(new StringRedisSerializer()); | ||
|
||
// Use Jackson2JsonRedisSerializer for values (Users objects) | ||
Jackson2JsonRedisSerializer<Users> serializer = new Jackson2JsonRedisSerializer<>(Users.class); | ||
template.setValueSerializer(serializer); | ||
|
||
return template; | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.iemr.hwc.utils; | ||
|
||
import java.util.Arrays; | ||
import java.util.Optional; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import jakarta.servlet.http.Cookie; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
|
||
@Service | ||
public class CookieUtil { | ||
|
||
public Optional<String> getCookieValue(HttpServletRequest request, String cookieName) { | ||
Cookie[] cookies = request.getCookies(); | ||
if (cookies != null) { | ||
for (Cookie cookie : cookies) { | ||
if (cookieName.equals(cookie.getName())) { | ||
return Optional.of(cookie.getValue()); | ||
} | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
public String getJwtTokenFromCookie(HttpServletRequest request) { | ||
return Arrays.stream(request.getCookies()).filter(cookie -> "Jwttoken".equals(cookie.getName())) | ||
.map(Cookie::getValue).findFirst().orElse(null); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Generic type usage in RedisTemplate can lead to type mismatches if not carefully handled.
RedisTemplate<String, Object>
but only configuring the value serializer forUsers
. If you plan to store other object types, consider a more universal approach or define multiple templates with narrower type parameters.RedisConfig
, confirm that storedUsers
objects remain compatible through version changes.