如何在Grails中创建禁区?

时间:2011-04-26 10:23:17

标签: authentication grails

如何在某些页面(创建/编辑/删除视图和控制器)上设置密码(如果它在数据库中最好,那么实体有一条记录)?它可以用密码字段的表格重定向到入口页面。

2 个答案:

答案 0 :(得分:2)

我还建议你使用'spring security core'插件。

通过使用spring security core,您将能够:

(1) secure all of your project's possible URLs
(2) provide access to required pages to particular role
(3) assign one or more then one role to particular user
(4) manage individual users with basic information as well as storing password into encrypted form etc.
(5) Its in-built reach set of tag library will help you alot to reduce the logical code.

除此之外,使用Spring安全核心的主要优势在于其简单性和可扩展性。正如其先进的功能如下:

LDAP
ACL
OpenID
CAS etc

可以使用不同的插件。

还有一个名为“spring security ui”的插件可用,它将在一分钟内为您提供所有UI页面(使用gsps,控制器)。

我在一年之前在我的项目中使用过此插件,我强烈建议大家使用它...

您可以查看其简单的用户指南here

答案 1 :(得分:1)

使用其中一个安全插件,并使您想要保护的操作仅对具有特定角色的用户可用。如果未经身份验证的用户尝试访问其中一个操作,系统将提示他们登录,并且只有在为其分配了相关角色后才会允许调用该操作。

Spring安全插件是一个合理的选择,因为它提供了您需要的功能,可能是最受欢迎的Grails安全插件。