dimanche 15 juillet 2018

Spring Security UserDetails in multi-layered app

I have a service that consists of multiple layers: persistence layer, business layer, and access layer.

Central entity of my service is the User, which is represented by different classes through those layers:

  1. UserDTO: DTO's that are being sent from the service.
  2. UserBO: Objects that the service works with internally.
  3. UserTable: Objects that are stored to the Database.

Now I'm adding Spring Security to this architecture, where the user object needs to implement Spring's UserDetails to have the security features like login / access to secured endpoints etc.

The question is: which of one my objects through layers should be implementing the UserDetails? Is it always the database object (in my case - UserTable), or could it be UserBo and UserDTO too?

Aucun commentaire:

Enregistrer un commentaire