I have this basic delete request:
@DeleteMapping("/{id}")
public ResponseEntity<String> deleteSubscription(@PathVariable Long id) {
subscriptionService.deleteSubscription(id);
return ResponseEntity.noContent().build();
}
So I was told this is not ok because sensitive data (the id) gets exposed and a better way would be to use UUID but how to do it?
I am using Spring Data JPA, MariaDB.
I don't know how to really do it. The UUID must be the primary key to replace the id or some sort of generated & validated value?
Security:
Whether a uuid or a serial number should be used for security reasons depends on the requirements - which only you know. Any answer from this would be opinion based.
Also consider that MariaDB uses UUID type 1 (timestamp based), where timestamps can be extracted.
Technial aspects:
A serial (auto_increment) number should always be preferred over a UUID: