What is the best practice to protect some fields in a entity for being edited?

Viewed 52

I started playing around with JHipster and created my first JDL-Entities. I learned that an Entity can be "readonly", but is there a way to secure a field like "creationDate" is not changed by anyone? I added a [readonly]="true" to the input-tag in edit-view, but I want to secure the api behind as well.

There are any suggestions or best practices to do it a clean way?

1 Answers

You could use a DTO so that you select which fields of your entity you want to expose in service layer.

https://www.jhipster.tech/using-dtos/

JHipster uses MapStruct to generate DTOs but you can also do it manually.

Related