如何限制用户访问控制器的特定操作?
你好。 我的应用程序有两个用户。一个是管理员,其他访问者。我的控制器中有两个操作。我的管理员可以对这两个操作执行操作,但我希望限制访问者访问第二个操作。如何实现?
提前等待答复,谢谢,
HI.
I have two user's for my app.one is admin n other visitors..i have two actions in my controller.i admin can act on both but i want visitors to be restricted from accessing 2nd action.how to achieve it?
Waiting for answer with advance thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Spring Security 插件是最佳选择。 http://grails.org/plugin/spring-security-core
我建议使用注释方法。博客文章中有一个关于使用注释的部分 http ://blog.springsource.com/2010/08/11/simplified-spring-security-with-grails/
我建议完整阅读上面的博客文章,
例如控制器操作将受到保护,就像...... 。
这如果您不想强迫用户始终登录,插件还提供“记住我”选项
The spring security plugin is the way to go. http://grails.org/plugin/spring-security-core
I would recommend using the annotation approach. There is a section on using annotations in the blog post http://blog.springsource.com/2010/08/11/simplified-spring-security-with-grails/
I would recommend reading the above blog post in its entirety
E.g. Controller action would be secured like....
The plugin also offers a "remember me" option if you dont want to force your users to always login
我建议使用控制器拦截器 http://grails .org/doc/latest/guide/6.%20The%20Web%20Layer.html#6.1 控制器
或安装 Spring Security Core 插件 http://www.grails.org/plugin/spring-security-core。
I suggest to use the controllers interceptors http://grails.org/doc/latest/guide/6.%20The%20Web%20Layer.html#6.1 Controllers
or install the Spring Security Core plugin http://www.grails.org/plugin/spring-security-core.