more security on endpoint

This commit is contained in:
Olivier PARPAILLON
2025-07-16 12:45:44 +02:00
parent 682de82447
commit 2a13daaf30
2 changed files with 8 additions and 3 deletions

View File

@@ -30,15 +30,15 @@ public class StockController {
@GetMapping("/{id}")
public ResponseEntity<Map<String, Object>> findById(@PathVariable Long id) {
Optional<Stock> result = stockService.findById(id);
return buildResponse("Stock added", true, result);
return buildResponse("Stock fetched", true, result);
}
// Trouver les jeux par nom et compter le result par nom
// ACCESS PUBLIC
@GetMapping("/{name}")
@GetMapping("/search/{name}")
public ResponseEntity<Map<String, Object>> findByName(@PathVariable String name) {
List<StockCount> result = stockService.findAllByName(name);
return buildResponse("Stock added", true, result);
return buildResponse("List stock fetched", true, result);
}
private ResponseEntity<Map<String, Object>> buildResponse(String message, boolean status, Object data) {

View File

@@ -38,6 +38,11 @@ public class SecurityConfig {
.authorizeHttpRequests(auth -> auth
.requestMatchers("/api/auth/login").permitAll()
.requestMatchers("/api/clients/**").hasRole("EMPLOYE")
.requestMatchers("/api/address/**").hasRole("EMPLOYE")
.requestMatchers("/api/facture/**").hasRole("EMPLOYE")
.requestMatchers("/api/gametype/**").hasRole("EMPLOYE")
.requestMatchers("/api/location/**").hasRole("EMPLOYE")
.requestMatchers("/api/stock/search/**").permitAll()
.anyRequest().authenticated()
)
.sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS))