Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we use ASP.NET Identity in Domain Driven Design?

Our team decided to use Domain Driven Design architecture for our project. Now the discussion is going on for, "can we use ASP.NET Identity in DDD?".

Is there any disadvantages on using ASP.NET identity in DDD design.

I'm in a confusion to make a decision on it.

I have searched for it, but I didn't get any idea.

Any help would be appreciable.

like image 202
RajeshKannan Avatar asked Apr 01 '14 06:04

RajeshKannan


People also ask

What is ASP NET identity used for?

ASP.NET Core Identity: Is an API that supports user interface (UI) login functionality. Manages users, passwords, profile data, roles, claims, tokens, email confirmation, and more.

Which EF approach we can use for domain driven design?

Advanced EF: Mapping DDD to EF Core. Domain Driven Design is a great way to start designing your applications. Entity Framework Core is a great framework to access and manipulate your data, stored in databases.

Is domain driven design still relevant?

Domain Driven Design (DDD) has recently gained additional popularity, as evidenced by new books, conference talks, and even complete conferences dedicated to it), and lots of trainings – including some by our very own colleagues here at INNOQ.

What is ASP Net Identity in MVC?

ASP.NET Identity is the membership system for authentication and authorization of the users by building an ASP.NET application. The ASP.NET Identity is a fresh look at what the membership system should be when you are building modern applications for the web, phone or tablet.


1 Answers

The questions reveals several misconceptions:

It appears that you perceive the domain model as some monolithic model where you put every piece of application in. Instead, concentrate on strategic patterns to distinguish Bounded Contexts. Consider the domain as a composition of several loosely interconnected components. Then identify what your core domain is and apply DDD tactical patterns there. Not every ccomponent needs DDD. Some of them even should not use DDD. Especially - generic domains, like Authentication.

DDD is technology agnostic (to some point) so yes, you can use ASP.NET Identity or whatever library you like.

Authentication typically belongs to the Application layer, not Domain layer.

However - if in your domain there is a concept of a user/client/person, it might be required to use the identity provided by the identity component. But you have to understand that the meaning of User in your bounded context is different than meaning of User in Identity component. These are not the same concept. Although they both refer to the same physical person sitting somewhere and clicking on your app's GUI, they are 2 different models (or projections) of him that serve different purposes. So you shouldn't just reuse the ASP.NET User class in your bounded context.

Instead - separate contexts should communicate via an anticorruption layer. Basically you have to make some service (interface only) in your bounded context that produces context-specific User objects. The implementation of that interface made in infrastructure layer will be a wrapper of ASP.NET Identity that gets ASP.NET Identity user and produce corresponding bounded context's user.

like image 134
Bartłomiej Szypelow Avatar answered Sep 17 '22 11:09

Bartłomiej Szypelow