Issue
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?
Solution
You can use Expression-Based Access Control
@GetMapping("/{s}")
@PreAuthorize("@myMethod(#s, Constant.WRITE")
public ResponseEntity<MyDto> getDto(
@PathVariable("s") String s
) {}
Answered By - Nemanja
Answer Checked By - Willingham (JavaFixing Volunteer)