与Spring MVC的基于角色的访问控制 [英] Role-based access control with Spring MVC
问题描述
我想知道有弹簧的基于角色的访问控制的最佳实践。
I would like to know the best practices for the role based access control with spring.
我的要求是,
我已经设置分配给用户的角色说,
I will have set of roles assigned to users say,
USER1 =管理员,用户2 =专家
USER1将有访问这样写
user1 will have the accesses write like
/管理/会员管理
/管理/项目管理
......
,对于user2 ....
for user2....
/ myproject1 / *
/myproject1/*
所以,如果user2的尝试访问网址
so if user2 tries to access the url
/管理/会员管理
将重定向到授权失败页面。
will be redirect to authorization failure page.
推荐答案
与Spring MVC的使用标准框架的春季安全。虽然它可以是非常复杂的,这里有你所需要的最低版本:的 4.2.2最低配置
The standard framework to use with Spring MVC is Spring Security. While it can be very complex, here's a minimal version of what you need: 4.2.2 A Minimal Configuration
在你的情况下,配置将是这样的:
In your case, the config would be something like this:
<http auto-config='true'>
<intercept-url pattern="/admin/**" access="ROLE_ADMIN" />
</http>
这篇关于与Spring MVC的基于角色的访问控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!