Spring Security 能满足这些需求吗?

发布于 2024-10-25 05:44:17 字数 715 浏览 3 评论 0原文

我已经在网站上阅读了一些有关 Spring Security 提供的功能..

但我只是想在深入研究甚至推出我自己的简单解决方案之前确定一下,希望能够得到使用 Spring Security 的经验丰富的开发人员的一些确认。

我目前正在使用 jsf2 + primefaces、spring3、jpa2 + hibernate 进行开发

我有这些需求:

  1. 拥有用户列表,用户组
  2. 需要在登录时对用户进行身份验证(这是非常基本的,必须已经支持)
  3. 安全系统可以为模块(java项目的包或可以被视为UI中的菜单/程序)进行配置,因此如果用户配置为能够访问菜单1和菜单3中的所有程序,并且只能访问菜单4中的1个程序,那么只有允许的菜单才会显示,直接访问不允许的菜单/程序 URL 会导致错误。
  4. 需要在只读级别、读/写级别等级别的服务方法(普通 java 方法)上对用户进行身份验证。例如,如果我们可以将 public void save(...) 配置为具有读/写访问权限,则只有获得读/写访问权限的用户才能调用此方法
  5. ,甚至可以在 JSF 2 xhtml 上扩展此方法,我可以利用 r 或 r/w 访问来启用/禁用按钮或链接或其他内容,可能以编程方式使用 jsf 组件的禁用属性。
  6. 如果其中一些功能(例如验证程序或服务方法)使用 AOP 透明地完成,而不弄脏业务流程代码,那就更好了。

请分享您对此的看法..

谢谢!

I've read the features a little bit on the site about what spring security offers ..

But i just want to make sure before diving down or even rolling my own simple solution, hoping some confirmations from experienced developers that made use of Spring security.

Im currently developing using jsf2 + primefaces, spring3, jpa2 + hibernate

I have these needs :

  1. have the list of users, and groups of users
  2. need to authenticate the user on login (this is so basic, it must be supported already)
  3. the security system can be configured for modules (packages of the java project or can be seen as menus / programs in the UI), so if user is configured to be able to access all programs in menu 1 and menu 3 and only 1 program in menu 4, then the menu will be displayed only for the allowed, and accessing directly on the unallowed menu / program URL will cause error.
  4. need to authenticate user on the service methods (plain java methods) on levels like readonly level, r/w level. So for example, if we can configure that public void save(...) to have the r/w access, only users that's given r/w access can call this method
  5. can even extend this on the JSF 2 xhtml, where i can make use of the r or r/w access to enable / disable buttons or links or other stuffs, perhaps programatically using the disabled attribute of a jsf component.
  6. would be better if some of these features like authenticating the program or the service methods are done transparently using AOP, without dirtying the business processes codes.

Please share your opinions on this ..

Thank you !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你是暖光i 2024-11-01 05:44:17

Spring Security 将支持您的大部分需求。

  1. 您可以使用角色来实现这一点。例如:用户、管理员、贡献者等。请参阅 http://static.springsource.org/spring-security/site/docs/3.0.x/reference/technical-overview.html
  2. 您可以使用
    form-login 元素嵌套在安全配置中的 http 元素中。请参阅 http: //static.springsource.org/spring-security/site/docs/3.0.x/reference/ns-config.html#ns-getting-started
  3. 在视图方面,您可以使用标签库控制谁看到什么在您使用 JSP 时。请参阅http://static.springsource.org/ spring-security/site/docs/3.0.x/reference/taglibs.html 然后在服务器端,您确保发出特定调用的人有权这样做。您可以在 URL 级别和方法级别进行控制。例如,对于 URL,您可以将拦截 url 元素嵌套在 http 中。您可以使用 @Secured 注释来保护方法
  4. 不确定对特定方法的读/写是什么意思,但正如 #3 中提到的,您可以使用注释来保护方法
  5. 不确定 JSF 允许您做什么,但是如果您使用 JSP,您可以使用前面所述的标记库
  6. 应该能够这样做,但我无法为您提供任何示例。我也想阅读其他人关于这一点的文章。

Spring Security would support most of your requirements.

  1. You can use the roles for that. For instance: USER, ADMIN, CONTRIBUTOR, etc. See http://static.springsource.org/spring-security/site/docs/3.0.x/reference/technical-overview.html
  2. That you can do with the
    form-login element nested in the http element in your security configuration. See http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ns-config.html#ns-getting-started
  3. On the view side, you can control who sees what using taglibs in you use JSPs. See http://static.springsource.org/spring-security/site/docs/3.0.x/reference/taglibs.html Then on the server side, you make sure that whoever made a particular call had the right to do so. You can control at the URL level and at the method level. For instance, for the URL, you have the intercept-url element nested in http. You can protect a method with @Secured annotation
  4. Not sure what you mean by read/write for a particular method but as mentioned in #3, you can use an annotation to secure a method
  5. Not sure what JSF allows you to do, but if you use JSPs, you can use the taglibs as stated before
  6. You should be able to do so but I can't provide you with any examples though. I'd like to read from others too on this one.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文