Danilo Silva
Danilo Silva

Reputation: 25

User entity in domain layer in ASP.NET Core in Clean Architecture

thinking in an application that needs User authentication/authorization in the context of Clean Architecture and DDD, how can I decouple de User entity in my domain layer from the Identity of the ASP.NET Core, ie, how can I put the User in my domain layer without referencing Identity (which is a Infrastructure detail) and still in some way using the ASP.NET Core Identity, it is even possible?

Upvotes: 1

Views: 1000

Answers (1)

Gordon Khanh Ng.
Gordon Khanh Ng.

Reputation: 1680

AFAIK, If clean Architecture and DDD was that importance from your viewpoint. I would assume we would heading to build a microservices architecture.

If that's the case, IMO, we should choose another approach that separate Asp.Net UserIdentity as central identity provider, and a user service that serve our own purpose for the business ourself.

As such, User entity of Asp.net would responsible for all the from login, 2 factor authentication, external identity service provider, mapping with current existing account,...

Our own application User identity would serve specific business logic, as user role, address, rewarding point,...

So, perfectly satisfied both bounded context of DDD and clean architecture for each service themself.

Upvotes: 0

Related Questions