[英]Profile into spring-security
我对春季安全性有疑问,它涉及:
<authentication-manager>
<authentication-provider>
<user-service>
我需要用户名可以执行一些与其他用户的其他操作不同的操作,即,
User Admin can make: create, read, delete, update.
User A can make: create, read, update.
User B can make: read, delete.
每个用户都是具有不同操作的不同配置文件。
我可以使用弹簧护具吗? 在数据库中类似于:
两个用户都访问相同的页面,但具有不同的操作,例如,www.myApp.com / pageOperation。
谢谢。
在Spring Security中,某些动作调用的权限存储为Grants集合中当前Authentication对象中的GrantedAuthority对象,因此,您应该通过检查用户名为不同的用户提供不同的权限集合。 您可以将它们硬编码到<user-service>
部分,或者提供UserDetailService的自己的实现,该实现根据用户名解析用户权限。 UserDetailsService
具有方法loadUserByUsername ,该方法接受用户名并返回包含用户权限集合的UserDetails实体。 您可以在用户调用某些操作时检查其权限,方法是对目标方法应用@PreAuthorize
批注或拦截适当的URL。 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.