使用 spring security 根据登录用户的权限控制菜单项

发布于 2024-10-09 06:13:58 字数 469 浏览 0 评论 0原文

基于 此链接 我已经合并了 spring我的 grails 项目的安全核心模块...我通过仅将每个角色、用户和请求映射存储在数据库中来使用 Requestmap 概念...

现在我的要求是根据用户分配的角色提供菜单项...对于例如:

如果我的“用户”主菜单有以下项目: 仪表板 导入用户 管理用户

如果我已将仪表板和导入用户角色分配给用户名为“审核员”的用户,则屏幕上应仅显示以下菜单项: 用户(主菜单) ->仪表板(子菜单) ->导入用户(子菜单)

我已经探索了 Spring Security ACL 插件,但它使用域类来使其工作...

所以,想知道这样做的便捷方法...

提前致谢.. 。

Based on this link I have incorporated the spring security core module with my grails project... I am using the Requestmap concept by storing each role, user and requestmap inside the database only...

Now my requirement is to provide the menu items based on the users assigned roles... For e.g.:

If my "User" Main Menu have following Items :
Dashboard
Import User
Manage User

And if I have assigned a roles of Dashboard and Import User to the user with a username "auditor" then, only following Menu items should be displayed on the screen :
User (Main Menu)
-> Dashboard (sub menu)
-> Import User (sub menu)

I have explored the Spring Security ACL plugin for the same, but it's using the Domain classes to get it working...

So, wanted to know the convenient way to do so...

Thanks in advance...

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

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

发布评论

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

评论(1

叫嚣ゝ 2024-10-16 06:13:58

ACL 插件看起来有点大材小用。我会使用插件附带的标签库;请参阅文档中的“6.1 SecurityTagLib”部分。

将呈现子菜单的 GSP 代码包含在 menu code here

The ACL plugin seems like overkill. I'd use the taglib that comes with the plugin; see section "6.1 SecurityTagLib" in the docs.

Wrap the code in the GSP that renders the submenus with <sec:ifAllGranted roles="...">menu code here</sec:ifAllGranted>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文