I want to secure a REST service for personal use and used as a backed for an Angular app using method to method security like this.
@PreAuthorize("hasPermission(#id, 'Player', 'expenseReport.allowed')")
@GetMapping(value = "editplayer")
@CrossOrigin(origins = crossorg)
public Player getEditPlayerAuthorize(@RequestParam Long id){
return fetcher.fetchPlayer(id);
}
The @CrossOrigin annotation works perfectly where, but when I try the same on a POST request it fails because of CORS:
@PostMapping(value = "login", produces = "application/json")
@CrossOrigin(origins = crossorg)
public Login attemptLogin(@RequestBody Login payload) {
return handler.attemptLogin(payload);
}
So I guess Spring Boot security is somehow interfering in this, but I see no solution why this should affect only POST requests? They worked fine before I added Spring Boot Security.