asp.net mvc - On Which Tier should user authentication should exist in n-tier website -


i went through different architecture books such one: microsoft application architecture guide, 2nd edition , building new n-tier website asp.net mvc presentation layer. question is, if use asp.net identity, on tier/layer should implement user authentication?

i thought should in cross cutting concerns, because need check if user authorized or authenticated access functions plus may use user name on many tiers, such business, services , presentation layer.

and thought better put in presentation layer specially because presentation layer mvc , easy deal asp identity there , allow me user [authorize] , [allowanonymous] easily.

i know question answer depend on many other factors trying here achieve best practice, need point of view , discuss it.

there quite few similar questions here on stackoverflow, , many answers. here view on matter.

you have separate abstraction implementation.

the abstraction (an interface) defines questions need able ask authentication service. interface used other parts of application going use authentication service. means abstraction must defined somewhere can referenced other parts of application. suggestion put in business layer, since methods in interface (in other words 'questions want ask service') business related. suggestion put in core layer (if have one).

that leaves implementation of interface. implement in easiest place can works. can in business layer, fine. need use identity classes mvc, too, place there. doesn't matter put it, since isn't used directly.

of course, make work need use little dependency injection, register implementation interface.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -