-
Notifications
You must be signed in to change notification settings - Fork 22
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 implementation changes #53
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,4 +95,5 @@ logging.level.com.iemr=DEBUG | |
logging.level.org.springframework=INFO | ||
|
||
#ELK logging file name | ||
[email protected]_API_LOGGING_FILE_NAME@ | ||
[email protected]_API_LOGGING_FILE_NAME@ | ||
jwt.secret=@JWT_SECRET_KEY@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,3 +93,4 @@ logging.level.org.springframework.web=INFO | |
logging.level.org.hibernate=INFO | ||
logging.level.com.iemr=DEBUG | ||
logging.level.org.springframework=INFO | ||
jwt.secret=@JWT_SECRET_KEY@ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Codebase verification Review concerns about test environment JWT configuration are valid Based on the verification results:
Recommendations:
π Analysis chainEnhance test environment security configuration For the test environment:
Let me gather more information about JWT configuration across different environments to verify the concern. Let me check the content of these JWT-related files and properties to better understand the configuration and validation mechanisms. π Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check for JWT configuration validation
echo "Checking for JWT configuration validation..."
rg -l "JwtConfig.*validate|validateJwtConfig" || echo "No JWT configuration validation found"
# Look for JWT-related test files
echo "Checking for JWT-related tests..."
fd -e java -e kt -e groovy --full-path ".*[Tt]est.*" | rg "JWT|[Jj]wt" || echo "No JWT-related test files found"
Length of output: 454 Script: #!/bin/bash
# Check JWT configuration across different environments
echo "Checking JWT configuration across environments..."
rg "jwt\.secret" --type properties
# Look for JWT-related configuration classes and security setup
echo "Checking JWT-related configuration classes..."
rg -l "class.*[Jj]wt"
# Check for any JWT token generation or validation logic
echo "Looking for JWT token handling..."
ast-grep --pattern 'class $_ {
$$$
$_(JWT|[Jj]wt)$_ {
$$$
}
$$$
}'
Length of output: 639 Script: #!/bin/bash
# Check JWT utility class implementations
echo "Checking JWT utility implementations..."
rg -A 10 "class JwtUtil" src/main/java/com/wipro/fhir/utils/JwtUtil.java
# Check JWT filter implementation
echo "Checking JWT filter implementation..."
rg -A 10 "class JwtUserIdValidationFilter" src/main/java/com/wipro/fhir/utils/JwtUserIdValidationFilter.java
# Check properties files for JWT configuration
echo "Checking properties files for JWT configuration..."
fd -e properties | xargs rg "jwt"
Length of output: 1637 |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,74 @@ | ||||||||||||||||
package com.wipro.fhir.data.users; | ||||||||||||||||
|
||||||||||||||||
import java.sql.Timestamp; | ||||||||||||||||
|
||||||||||||||||
import com.google.gson.annotations.Expose; | ||||||||||||||||
|
||||||||||||||||
import jakarta.persistence.Column; | ||||||||||||||||
import jakarta.persistence.Entity; | ||||||||||||||||
import jakarta.persistence.GeneratedValue; | ||||||||||||||||
import jakarta.persistence.GenerationType; | ||||||||||||||||
import jakarta.persistence.Id; | ||||||||||||||||
import jakarta.persistence.Table; | ||||||||||||||||
import lombok.Data; | ||||||||||||||||
|
||||||||||||||||
@Entity | ||||||||||||||||
@Table(name = "m_user") | ||||||||||||||||
@Data | ||||||||||||||||
public class User { | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Replace @DaTa with more specific Lombok annotations Since this is a security-sensitive entity used for JWT authentication, using -@Data
+@Getter
+@Setter
+@EqualsAndHashCode(of = "userID")
+@ToString(exclude = {"userName"})
public class User { π Committable suggestion
Suggested change
|
||||||||||||||||
@Id | ||||||||||||||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "UserID") | ||||||||||||||||
private Long userID; | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove @expose annotation from sensitive fields The Consider removing |
||||||||||||||||
|
||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "TitleID") | ||||||||||||||||
private Integer titleID; | ||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "FirstName") | ||||||||||||||||
private String firstName; | ||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "MiddleName") | ||||||||||||||||
private String middleName; | ||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "LastName") | ||||||||||||||||
private String lastName; | ||||||||||||||||
|
||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "GenderID") | ||||||||||||||||
private Integer genderID; | ||||||||||||||||
|
||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "MaritalStatusID") | ||||||||||||||||
private Integer maritalStatusID; | ||||||||||||||||
|
||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "StatusID") | ||||||||||||||||
private Integer statusID; | ||||||||||||||||
|
||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "DOB") | ||||||||||||||||
private Timestamp dOB; | ||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "DOJ") | ||||||||||||||||
private Timestamp dOJ; | ||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "QualificationID") | ||||||||||||||||
private Integer qualificationID; | ||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "userName") | ||||||||||||||||
private String userName; | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Add validation constraints and establish relationships The entity lacks validation constraints and proper relationships:
Apply these improvements: + @Column(name = "userName", unique = true, length = 50)
+ @NotBlank(message = "Username is required")
private String userName;
+ @ManyToOne
+ @JoinColumn(name = "TitleID")
+ private Title title;
+ @Size(max = 50)
+ @NotBlank(message = "First name is required")
@Column(name = "FirstName")
private String firstName;
Comment on lines
+24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Add validation and uniqueness constraints |
||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "Deleted", insertable = false, updatable = true) | ||||||||||||||||
private Boolean deleted; | ||||||||||||||||
@Expose | ||||||||||||||||
@Column(name = "CreatedBy") | ||||||||||||||||
private String createdBy; | ||||||||||||||||
@Column(name = "CreatedDate", insertable = false, updatable = false) | ||||||||||||||||
private Timestamp createdDate; | ||||||||||||||||
@Column(name = "ModifiedBy") | ||||||||||||||||
private String modifiedBy; | ||||||||||||||||
@Column(name = "LastModDate", insertable = false, updatable = false) | ||||||||||||||||
private Timestamp lastModDate; | ||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,11 @@ | ||||||
package com.wipro.fhir.repo.user; | ||||||
|
||||||
import org.springframework.data.repository.CrudRepository; | ||||||
|
||||||
import com.wipro.fhir.data.users.User; | ||||||
|
||||||
public interface UserRepository extends CrudRepository<User, Long> { | ||||||
|
||||||
User findByUserID(Long userID); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Use standard naming conventions for repository methods Spring Data JPA uses naming conventions for query methods. The Apply this diff to correct the method name: - User findByUserID(Long userID);
+ User findByUserId(Long userId); π Committable suggestion
Suggested change
|
||||||
|
||||||
} |
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
Improve example property documentation and security
jwt.secret=<Enter a strong secret key with minimum 32 characters>
)π Committable suggestion