如何将访问控制注入到 mvc 应用程序的服务层中?
我正在使用标准 mvc 范例编写 zend 框架应用程序,并添加一个服务层来处理应用程序/业务逻辑。将访问控制放入服务中似乎很流行,而不是模块/控制器/操作中,但是,我只看到了具有静态角色和这些角色的权限的简单示例。
我的应用程序将使用动态 acl,允许管理员用户添加角色并设置这些角色的权限。我有两个问题:
- 如何将用户空间中的权限映射到服务和服务中的方法的权限?我不认为它应该是 1:1 的映射。如果您的应用程序足够大,您将拥有许多具有多种方法的服务,并且对于为角色设置权限的最终用户来说,权限结构很快就会变得混乱。
- 我的服务对于应用程序来说是全局的,而不是特定于模块的。您将如何根据访问的模块设置这些服务的权限?
任何帮助将不胜感激。
I'm coding a zend framework application using the the standard mvc paradigm with an added service layer to take care of application/business logic. It seems quite popular to put your access control into your services, rather than your modules/controllers/actions, however, I have only seen simple examples with static roles and permissions for those roles.
My application will be using a dynamic acl, allowing the admin user to add roles and set permissions on those roles. I have two questions:
- How do you map permissions in user land to that of services and methods in services? I don't believe it should be a 1:1 mapping. If your application is sufficiently large, you will have many services with many methods, and the permission structure will quickly become confusing for an end user setting permissions for a role.
- I have services that are global to the application and not specific to a module. How would you set permissions for those services based on the module that is accessed?
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论