shiro中怎么通过数据库方式,将一个URL资源授权给某个用户、角色?
此处说的不很准确 是默认没有 目前大多在方法上加验证注解实现 这个功能(因为shiro比spring security更细粒度化)
它虽然有基于url的验证
[url]http://shiro.apache.org/web.html#Web-webini[/url]
/index.html = anon
/user/create = anon
/user/** = authc
/admin/** = authc, roles[administrator]
/rest/** = authc, rest
/remoting/rpc/** = authc, perms["remote:invoke"]
但是如果不改正 如默认如果指定多个角色 是且的关系
/role1ORrole2/** = authc, roles[role1,role2] 且
你可以实现 FilterChainManager 去自定义
[url]https://github.com/exitsoft/exit-web-framework/wiki/apache-shiro%E4%B8%8Espring%E6%95%B4%E5%90%88%E3%80%81%E5%8A%A8%E6%80%81filterChainDefinitions%E3%80%81%E4%BB%A5%E5%8F%8A%E8%AE%A4%E8%AF%81%E3%80%81%E6%8E%88%E6%9D%83[/url]
[url]http://rayoo.iteye.com/blog/1838224[/url]
[url]http://www.360doc.com/content/12/0104/13/834950_177177202.shtml[/url]
没有 你可以在方法上加验证注解 里实现 这个功能
shiro与spring security类似,如果使用数据库方式,就需要配置jdbc方式的realm。shiro对于jdbc的支持类为:
org.apache.shiro.realm.jdbc.JdbcRealm
只需要在spring的bean配置中使用这个realm就可以使用数据库方式了。如下:
[code="java"]
<!-- The 'bootstrapDataPopulator' Sha256 hashes the password (using the
username as the salt) then base64 encodes it: -->
<!-- true means hex encoded, false means base64 encoded -->
<!-- We salt the password using the username, the most common practice: -->
[/code]
可参考:[url]http://www.blogjava.net/paulwong/archive/2012/01/28/368930.html[/url]
配置好之后,需要把这个reaml放到securityManager的realm属性中