Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
背景:
admin可添加自定义页面,或者是其它系统进行内嵌,菜单栏目前没有权限控制,有安全性、越权等相关问题。
解决:
使用Django内部的权限系统,调用
user.get_all_permissions()
,渲染自定义菜单栏时,判断对应的菜单栏是否在用户权限列表中。SIMPLEUI_CONFIG的
menus`,主菜单,或者是多级菜单支持配置permission字段,作为权限控制案例:
如果用户拥有:
account.view_accountmodel
权限,那么菜单1-1-1
无权访问效果: