如果用戶有權限user:edit:1
,並且我使用註釋驅動@RequiresPermissions("user:edit")
爲什麼shiro引發異常?他們是否有user:edit:1
這個事實,不應該暗示這種許可?如果我輸入@RequriesPermissions("user:edit:1")
那麼它可以正常工作,但在操作的上下文中,我不會知道什麼是1,所以稍後會在方法中檢查,但是我想避免進入方法,根本沒有user:edit
權限。Apache shiro隱含權限
0
A
回答
1
"user:edit"
暗示"user:edit:1"
但不是相反。 您可以繼續使用@RequiresPermissions("user:edit")
,然後在您的方法中檢查「1」。你也可以使用通配符@RequiresPermissions("user:edit:*")
,這是完全一樣的,但我認爲它更清晰。
3
我不認爲,ascandrolis答案是正確的,因爲四郎文檔狀態:
但是下面是一個運行時檢查理想的要少得多:
if (SecurityUtils.getSubject().isPermitted("printer:print")) {
//print the document
}
爲什麼?因爲第二個例子說「您必須能夠打印到任何打印機以執行以下代碼塊」。但請記住,「打印機:打印」相當於「打印機:打印:*」!
所以@RequiresPermissions("user:edit:*")
裝置一樣@RequiresPermissions("user:edit")
,即該主要需要能夠編輯的任何用戶。
相關問題
- 1. Apache Shiro的存儲權限
- 2. Apache Zeppelin(Shiro Security)無法保存註釋權限
- 3. Apache Shiro角色和權限不起作用
- 4. Apache權限
- 5. Shiro權限字符串拒絕功能?
- 6. 您沒有權限... spring security shiro
- 7. Apache Shiro 1.2.4 - 1.3.2
- 8. apache Shiro登錄
- 9. Apache Shiro和SSO
- 10. Apache用戶權限
- 11. Apache文件權限
- 12. Apache Shiro per object permission?
- 13. Apache shiro塊p:imageCropper primefaces
- 14. Apache Shiro:權限過濾器正在驗證上次匹配的路徑
- 15. Django權限隱藏「auth |權限」
- 16. 如何確定一個shiro用戶擁有哪些權限
- 17. Apache FTP文件權限
- 18. 文件權限安全apache
- 19. Mac OSX Apache寫入權限
- 20. apache + redmine 403 - 權限很好
- 21. Apache文件夾權限
- 22. php apache root寫入權限
- 23. Apache 2.4權限問題
- 24. 配置Apache四郎權限
- 25. linux apache/PHP讀寫權限
- 26. apache中的django mkdir權限
- 27. Apache Shiro JDBC連接問題
- 28. Apache shiro LDAP多個OU
- 29. 掛毯apache shiro requireroles註釋
- 30. Apache Shiro與LDAP相結合
請再次閱讀問題,答案和文檔,仔細閱讀並注意措辭:用戶「擁有」什麼,需要什麼以及開發人員事先知道什麼信息。 – ascandroli
抱歉,如果我的答案不像我的意思那麼清楚。我想說的是,兩個權限「user:edit」和「user:edit:*」是100%等價的,因此您使用後者的建議並不能解決操作系統接收安全異常的問題。只要自己嘗試一下(就像我一樣)。 – martin
替代方案可能與[this]類似(http://blog.42.nl/articles/spring-security-accessing-spring-beans-from-your-security-annotations):在自定義中執行shiro檢查bean並通過註釋調用它,或者甚至更好:通過使用自定義[WebSecurityExpressionRoot](http://static.springsource.org/spring-security/site/docs/3.1.x/apidocs/org/springframework/security/ web/access/expression/WebSecurityExpressionRoot.html),您可以訪問http請求,從而訪問客戶端提供的id。 – martin