简体   繁体   中英

Implement Authorization in BLL (for ASP.NET and other services)

I am looking for some form of how to guide or code samples on how to implement authorization in a Business Logic Layer. I have looked on the web and have been unable to find anything relating direct to BLL.

I need to enable authorization to allow users to access only their records. AAA is provided by ASP.NET Identity and I want to enable authorization at BLL so the web service and future projects will also be included.

It is not a good design to implement ASP.Net Identity in Business Logic Layer. BLL should not need to know about Principal object.

One of the reason is you should not need to mock HttpContextBase in order to unit test BLL services.

Another reason is if your UI is later changed to WPF, you need to update the entire BLL layer.

By and large, Principal object should stay at the Presentation Layer, and the you just pass UserId to BLL's service classes. Therefore, you won't be able to find any good guide which implements ASP.Net Identity in BLL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM