-
Notifications
You must be signed in to change notification settings - Fork 40
Release 3.6.0 into main #128
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
Changes from all commits
aef87aa
83061c4
50700d1
663f6f4
a1a015c
72a9de5
641cd30
667dc9c
45c5c1d
b135e9e
864be42
eb7d1fc
dc5b83a
910b96d
279033e
aa51c3d
fce5178
f8729ff
dbdfa12
e1a0d43
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 | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,11 +22,14 @@ | |||||||||||||||||||||||||||||||
| package com.iemr.common.identity.utils.http; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import java.util.Arrays; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import javax.ws.rs.core.MediaType; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import org.slf4j.Logger; | ||||||||||||||||||||||||||||||||
| import org.slf4j.LoggerFactory; | ||||||||||||||||||||||||||||||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||||||||||||||||||||||||||||||
| import org.springframework.beans.factory.annotation.Value; | ||||||||||||||||||||||||||||||||
| import org.springframework.stereotype.Component; | ||||||||||||||||||||||||||||||||
| import org.springframework.web.servlet.HandlerInterceptor; | ||||||||||||||||||||||||||||||||
| import org.springframework.web.servlet.ModelAndView; | ||||||||||||||||||||||||||||||||
|
|
@@ -42,6 +45,9 @@ public class HTTPRequestInterceptor implements HandlerInterceptor { | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @Value("${cors.allowed-origins}") | ||||||||||||||||||||||||||||||||
| private String allowedOrigins; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| private SessionObject sessionObject; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @Autowired | ||||||||||||||||||||||||||||||||
|
|
@@ -84,8 +90,13 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons | |||||||||||||||||||||||||||||||
| response.getOutputStream().print(output.toString()); | ||||||||||||||||||||||||||||||||
| response.setContentType(MediaType.APPLICATION_JSON); | ||||||||||||||||||||||||||||||||
| response.setContentLength(output.toString().length()); | ||||||||||||||||||||||||||||||||
| response.setHeader("Access-Control-Allow-Origin", "*"); | ||||||||||||||||||||||||||||||||
| status = false; | ||||||||||||||||||||||||||||||||
| String origin = request.getHeader("Origin"); | ||||||||||||||||||||||||||||||||
| if (origin != null && isOriginAllowed(origin)) { | ||||||||||||||||||||||||||||||||
| response.setHeader("Access-Control-Allow-Origin", origin); | ||||||||||||||||||||||||||||||||
| response.setHeader("Access-Control-Allow-Credentials", "true"); | ||||||||||||||||||||||||||||||||
| } else if (origin != null) { | ||||||||||||||||||||||||||||||||
| logger.warn("CORS headers NOT added for error response | Unauthorized origin: {}", origin); | ||||||||||||||||||||||||||||||||
| } status = false; | ||||||||||||||||||||||||||||||||
|
Comment on lines
+93
to
+99
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. Fix formatting: missing newline before statement. Line 99 has 🔧 Proposed formatting fix } else if (origin != null) {
logger.warn("CORS headers NOT added for error response | Unauthorized origin: {}", origin);
- } status = false;
+ }
+ status = false;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| return status; | ||||||||||||||||||||||||||||||||
|
|
@@ -115,4 +126,19 @@ public void afterCompletion(HttpServletRequest request, HttpServletResponse resp | |||||||||||||||||||||||||||||||
| throws Exception { | ||||||||||||||||||||||||||||||||
| logger.debug("In afterCompletion Request Completed"); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| private boolean isOriginAllowed(String origin) { | ||||||||||||||||||||||||||||||||
| if (origin == null || allowedOrigins == null || allowedOrigins.trim().isEmpty()) { | ||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return Arrays.stream(allowedOrigins.split(",")) | ||||||||||||||||||||||||||||||||
| .map(String::trim) | ||||||||||||||||||||||||||||||||
| .anyMatch(pattern -> { | ||||||||||||||||||||||||||||||||
| String regex = pattern | ||||||||||||||||||||||||||||||||
| .replace(".", "\\.") | ||||||||||||||||||||||||||||||||
| .replace("*", ".*"); | ||||||||||||||||||||||||||||||||
| return origin.matches(regex); | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
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.
Fix malformed logger statements.
Lines 1800 and 1802 have syntax errors in the logger calls:
logger.info("inside for check->",obj);- comma should be+for concatenationlogger.info("In for loop of importBenIdToLocalServer"+obj.getVanID());- missing space before concatenationThese will cause compilation errors or unexpected log output.
🔧 Fix logger syntax
🤖 Prompt for AI Agents