Separation of concerns and authentication
Posted
by Tom Gilder
on Stack Overflow
See other posts from Stack Overflow
or by Tom Gilder
Published on 2010-06-05T22:14:27Z
Indexed on
2010/06/05
22:22 UTC
Read the original article
Hit count: 426
I'm trying to be a Good Developer and separate my concerns out. I've got an ASP.NET MVC project with all my web code, and a DAL project with all the model code.
Sometimes code in the DAL needs to check if the current user is authorized to perform some actions, by checking something like CurrentUser.IsAdmin.
For the web site, the current is derived from the Windows username (from HttpContext.Current.User.Identity), but this is clearly a web concern and shouldn't be coupled to the DAL.
What's the best pattern to loosely couple the authentication? Should the DAL be asking the MVC code for a username, or the MVC be telling the DAL? Are there advantages or disadvantages to one or the other?
Thank you!
© Stack Overflow or respective owner