I'm very new to Spring. I'm trying to create a REST API using Spring Boot and I'm stuck whether to expose my user's primary key or not which also happens to be their email. Something like api/user/example@gmail.com
. A big part of me says it's okay since it would sensible to expose it as it is the identifier for that specific record when viewing, deleting, and updating. Is there a security risk for this? What is the best practice for such implementation? Right now I'm combining the @PathVariable and @RequestBody
. I didn't like the idea of putting my primary key in the RequestBody thinking that it might pose a risk...or is there?
@RequestMapping(value = "/updateUser/{customerEmail}", method = RequestMethod.POST)
public ApiResult updateCustomer(@RequestBody UserDetailsDto userDetailsDto, @PathVariable String customerEmail) {
//service call...
}