Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Identity in Domain Driven Design Architecture

Hi I'm starting a project using DDD.

I would like to use Asp.Net Identity for user authentication but IdentityUser this very coupled to Asp.net and a domain model object should not have dependencies.

This is leading me to think that authentication may be a different BoundedContext that is not implemented using DDD.

I would like to know if anyone has been in the same situation and what options you think I can have.

thanks

like image 323
xurxodev Avatar asked Oct 24 '25 21:10

xurxodev


1 Answers

For me it is fine to implement authentication without using DDD. DDD way is time consuming/expensive and it's fine to use it only to your core domain (code that has most business value).

And remember that if you want to separate yourself from frameworks you can always hide yourself behind Interface. In this case your business layer may declare IIdentityProvider with methods that your business layer require. Then you can provide concrete implementation of this provider AspIdentityProvider: IIdentityProvider in your website layer. Then AspIdentityProvider might be injected to classes in business layer that require it.

like image 106
Machet Avatar answered Oct 28 '25 04:10

Machet