more security on endpoint
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user