Skip to content

Commit

Permalink
Enhance CORS configuration and add PUT/PATCH restrictions for admin r…
Browse files Browse the repository at this point in the history
…oles in SecurityConfiguration
  • Loading branch information
LeonardoMeireles55 committed Jan 20, 2025
1 parent 52a770e commit f966b5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public class CorsConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(@NonNull CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins(
"http://localhost:3000, https://quality-lab-pro.vercel.app, https://68.183.141.155, https://68.183.141.155, https://leomeireles-dev.xyz, https://leomeireles-dev.xyz")
.allowedMethods("GET", "POST").allowedHeaders("*").allowCredentials(true)
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000", "https://quality-lab-pro.vercel.app",
"https://68.183.141.155", "https://leomeireles-dev.xyz")
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD")
.allowedHeaders("*").exposedHeaders("Authorization").allowCredentials(true)
.maxAge(3600);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti

// Add PUT and PATCH restrictions for admin
req.requestMatchers(HttpMethod.PUT, "/generic-analytics/**").hasRole("ADMIN");

req.requestMatchers(HttpMethod.PUT, "/biochemistry-analytics/**")
.hasRole("ADMIN");
req.requestMatchers(HttpMethod.PUT, "/hematology-analytics/**")
Expand All @@ -57,6 +58,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.hasRole("ADMIN");

req.requestMatchers(HttpMethod.PATCH, "/generic-analytics/**").hasRole("ADMIN");

req.requestMatchers(HttpMethod.PATCH, "/biochemistry-analytics/**")
.hasRole("ADMIN");
req.requestMatchers(HttpMethod.PATCH, "/hematology-analytics/**")
Expand Down

0 comments on commit f966b5c

Please sign in to comment.