I've got simple spring mvc controller
@GetMapping("/{s}")
@PreAuthorize("@myMethod(s, Constant.WRITE")
public ResponseEntity<MyDto> getDto(
@PathVariable("s") String s
) {}
So the problem is to pass the path variable to PreAuthorize annotation. Can SPeL help me in this situation?
CodePudding user response:
You can use Expression-Based Access Control
@GetMapping("/{s}")
@PreAuthorize("@myMethod(#s, Constant.WRITE")
public ResponseEntity<MyDto> getDto(
@PathVariable("s") String s
) {}