Spring mvc 具有Spring MVC通配符权限的Shiro不工作
我有以下几个权限:Spring mvc 具有Spring MVC通配符权限的Shiro不工作,spring-mvc,shiro,Spring Mvc,Shiro,我有以下几个权限: inventory:po:view inventory:po:create inventory:po:update 在JSP中,以下内容起作用: <shiro:hasPermission name="inventory:po:create"> <li><a href='<c:url value="/inventory/document/viewDocument?doctype=2" />'>Purchase Order&
inventory:po:view
inventory:po:create
inventory:po:update
在JSP中,以下内容起作用:
<shiro:hasPermission name="inventory:po:create">
<li><a href='<c:url value="/inventory/document/viewDocument?doctype=2" />'>Purchase Order</a></li>
</shiro:hasPermission>
然而,下面没有
<shiro:hasPermission name="inventory:po:*">
</shiro:hasPermission>
Shiro版本是1.2.1。我还尝试了使用subject.isPermitt()调用,但这也不起作用
我相信这应该是非常直接的,但是在启用通配符支持的配置中,我是否遗漏了什么?请给我一些建议
Shiro配置:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Security Manager -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="jdbcRealm" />
<property name="cacheManager" ref="cacheManager"/>
</bean>
<!-- Caching -->
<bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
<property name="cacheManager" ref="ehCacheManager" />
</bean>
<bean id="ehCacheManager"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" />
<bean id="sessionDAO"
class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO" />
<bean id="sessionManager"
class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
<property name="sessionDAO" ref="sessionDAO" />
</bean>
<!-- JDBC Realm Settings -->
<bean id="jdbcRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
<property name="name" value="jdbcRealm" />
<property name="dataSource" ref="dataSource" />
<property name="authenticationQuery"
value="SELECT password FROM system_user_accounts WHERE username=? and status=10" />
<property name="userRolesQuery"
value="SELECT role_code FROM system_roles r, system_user_accounts u, system_user_roles ur WHERE u.user_id=ur.user_id AND r.role_id=ur.role_id AND u.username=?" />
<property name="permissionsQuery"
value="SELECT code FROM system_roles r, system_permissions p, system_role_permission rp WHERE r.role_id=rp.role_id AND p.permission_id=rp.permission_id AND r.role_code=?" />
<property name="permissionsLookupEnabled" value="true"></property>
<property name="cachingEnabled" value="true" />
</bean>
<!-- Spring Integration -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
<!-- Enable Shiro Annotations for Spring-configured beans. Only run after
the lifecycleBeanProcessor has run: -->
<bean id="annotationProxy"
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
depends-on="lifecycleBeanPostProcessor" />
<bean id="authorizationAttributeSourceAdvisor"
class="org.apache.shiro.sprinemphasized textg.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager" />
</bean>
<!-- Secure Spring remoting: Ensure any Spring Remoting method invocations
can be associated with a Subject for security checks. -->
<bean id="secureRemoteInvocationExecutor"
class="org.apache.shiro.spring.remoting.SecureRemoteInvocationExecutor">
<property name="securityManager" ref="securityManager" />
</bean>
<!-- Passthrough for Login page -->
<bean id="passThruLogin" class="org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter">
<property name="loginUrl" value="/login" />
</bean>
<!-- Shiro filter -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager" />
<property name="loginUrl" value="/login" />
<property name="successUrl" value="/dashboard" />
<property name="unauthorizedUrl" value="/error" />
<property name="filters">
<map>
<entry key="authc" value-ref="passThruLogin" />
</map>
</property>
<property name="filterChainDefinitions">
<value>
<!-- !!! Order matters !!! -->
/authenticate = anon
/login = anon
/logout = anon
/error = anon
/static/** = anon
/** = authc
</value>
</property>
</bean>
/验证=anon
/登录名=anon
/注销=anon
/错误=anon
/静态/**=anon
/**=authc
在shiro的权限检查中,“*”不是通配符,相反,它表示“需要所有值”。
您应该声明自己的通配符权限(read通常是一个良好的默认通配符权限),并在权限检查中显式显示
相反,“*”的意思是“授予用户所有权利”,这让你与imho混淆了
从检查权限部分
if(SecurityUtils.getSubject().isPermitted(“打印机:打印”)){
//打印文档
}
因此,这是一个不正确的检查。如果当前用户没有能力打印到任何打印机,但他们有能力打印,例如lp7200和epsoncolor打印机,该怎么办。那么,上面的第二个示例将永远不允许他们打印到lp7200打印机,即使他们已被授予该能力
在shiro的权限检查中,“*”不是通配符,相反,它表示“需要所有值”。
您应该声明自己的通配符权限(read通常是一个良好的默认通配符权限),并在权限检查中显式显示
相反,“*”的意思是“授予用户所有权利”,这让你与imho混淆了
从检查权限部分
if(SecurityUtils.getSubject().isPermitted(“打印机:打印”)){
//打印文档
}
因此,这是一个不正确的检查。如果当前用户没有能力打印到任何打印机,但他们有能力打印,例如lp7200和epsoncolor打印机,该怎么办。那么,上面的第二个示例将永远不允许他们打印到lp7200打印机,即使他们已被授予该能力