spring-data-resthashids

Spring Data Rest ID conversion using HashIDs


We have a concern exposing internal IDs to the outside world. Therefore I'm thinking about using a hashing mechanism (current choice is hashids) to hash our IDs.

I tried to use a @JsonSerializer and @JsonDeserializer mapping on the Entities ID field. But this only takes effect when including the ID in the body, and has no impact on the IDs in the URL paths.

Is there a possibility to do this, e.g. something like an ID Translation SPI?


Solution

  • The only thing I can think of is to create a request filter that would take the request with encoded ID in URL, then decode the ID and redirect to an URL with decoded ID.