more security on endpoint
This commit is contained in:
@@ -30,15 +30,15 @@ public class StockController {
|
|||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ResponseEntity<Map<String, Object>> findById(@PathVariable Long id) {
|
public ResponseEntity<Map<String, Object>> findById(@PathVariable Long id) {
|
||||||
Optional<Stock> result = stockService.findById(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
|
// Trouver les jeux par nom et compter le result par nom
|
||||||
// ACCESS PUBLIC
|
// ACCESS PUBLIC
|
||||||
@GetMapping("/{name}")
|
@GetMapping("/search/{name}")
|
||||||
public ResponseEntity<Map<String, Object>> findByName(@PathVariable String name) {
|
public ResponseEntity<Map<String, Object>> findByName(@PathVariable String name) {
|
||||||
List<StockCount> result = stockService.findAllByName(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) {
|
private ResponseEntity<Map<String, Object>> buildResponse(String message, boolean status, Object data) {
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ public class SecurityConfig {
|
|||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers("/api/auth/login").permitAll()
|
.requestMatchers("/api/auth/login").permitAll()
|
||||||
.requestMatchers("/api/clients/**").hasRole("EMPLOYE")
|
.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()
|
.anyRequest().authenticated()
|
||||||
)
|
)
|
||||||
.sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
.sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||||
|
|||||||
Reference in New Issue
Block a user