Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit 697d99e

Browse files
authored
Merge pull request #16 from TechTorque-2025/MRR-Integration
Mrr integration
2 parents 7ee577f + e46bec4 commit 697d99e

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

auth-service/src/main/java/com/techtorque/auth_service/config/CorsFilter.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* The API Gateway applies CORS headers to all responses, so backend services should not
2222
* add CORS headers to avoid duplication.
2323
*/
24-
@Component
24+
// @Component - DISABLED: CORS is handled by API Gateway
2525
@Order(Ordered.HIGHEST_PRECEDENCE)
2626
public class CorsFilter implements Filter {
2727

@@ -37,8 +37,27 @@ public void init(FilterConfig filterConfig) {
3737
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
3838
throws IOException, ServletException {
3939

40-
// CORS is handled by the API Gateway, so we skip CORS header injection here
41-
// Just pass the request through without adding CORS headers
40+
HttpServletRequest httpRequest = (HttpServletRequest) request;
41+
HttpServletResponse httpResponse = (HttpServletResponse) response;
42+
43+
String origin = httpRequest.getHeader("Origin");
44+
45+
// If origin is present and allowed, add CORS headers
46+
if (origin != null && isOriginAllowed(origin)) {
47+
httpResponse.setHeader("Access-Control-Allow-Origin", origin);
48+
httpResponse.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH");
49+
httpResponse.setHeader("Access-Control-Allow-Headers",
50+
"Authorization, Content-Type, X-Requested-With, Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers");
51+
httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
52+
httpResponse.setHeader("Access-Control-Max-Age", "3600");
53+
}
54+
55+
// Handle preflight OPTIONS requests
56+
if ("OPTIONS".equalsIgnoreCase(httpRequest.getMethod())) {
57+
httpResponse.setStatus(HttpServletResponse.SC_OK);
58+
return;
59+
}
60+
4261
chain.doFilter(request, response);
4362
}
4463

auth-service/src/main/java/com/techtorque/auth_service/controller/UserController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ public class UserController {
4444
* Get a list of all users in the system.
4545
*/
4646
@GetMapping
47-
public ResponseEntity<List<UserDto>> getAllUsers() {
47+
public ResponseEntity<List<UserDto>> getAllUsers(@RequestParam(required = false) String role) {
4848
List<UserDto> users = userService.findAllUsers().stream()
4949
.map(this::convertToDto)
50+
.filter(user -> role == null || user.getRoles().contains(role))
5051
.collect(Collectors.toList());
5152
return ResponseEntity.ok(users);
5253
}

0 commit comments

Comments
 (0)