简体   繁体   English

在BLL中实施授权(针对ASP.NET和其他服务)

[英]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. 我浏览了网上,却找不到与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. AAA由ASP.NET Identity提供,我想在BLL启用授权,因此Web服务和将来的项目也将包括在内。

It is not a good design to implement ASP.Net Identity in Business Logic Layer. 在业务逻辑层中实现ASP.Net身份标识不是一个好的设计。 BLL should not need to know about Principal object. BLL不需要了解Principal对象。

One of the reason is you should not need to mock HttpContextBase in order to unit test BLL services. 原因之一是您不必为了对BLL服务进行单元测试而模拟HttpContextBase。

Another reason is if your UI is later changed to WPF, you need to update the entire BLL layer. 另一个原因是,如果您的UI稍后更改为WPF,则需要更新整个BLL层。

By and large, Principal object should stay at the Presentation Layer, and the you just pass UserId to BLL's service classes. 总的来说,Principal对象应该保留在Presentation Layer,而您只需将UserId传递给BLL的服务类。 Therefore, you won't be able to find any good guide which implements ASP.Net Identity in BLL. 因此,您将找不到任何在BLL中实现ASP.Net Identity的良好指南。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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