How to Implement authentication in a hexagonal/DDD architecture #45863
-
Hi everyone, I'm learning DDD using symfony, and I'm implementing the authentication I have a User entity which is in the auth domain, but I realize that I have to implement the UserInterface and PasswordAuthenticatedUserInterface of the symfony security component for my entity to be considered as a "user". Is there any other way to avoid using symfony interfaces in my domain? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can create a SecurityUser class in your Infrastructure folder, implement those interfaces there, and pass your User entity in the constructor. Methods in the Interface can then be forwarded to your entity. public function getUserIdentifier(): string
{
return $this->entity->getEmail();
} |
Beta Was this translation helpful? Give feedback.
You can create a SecurityUser class in your Infrastructure folder, implement those interfaces there, and pass your User entity in the constructor. Methods in the Interface can then be forwarded to your entity.