Shiro中的filterChainDefinitions详解

1,056 阅读1分钟

filterChainDefinitions

filterChainDefinitions 就是指定过滤规则的公共配置接口

  • DefaultShiroFilterChainDefinition 实现了 filterChainDefinitions接口
  • 一般我们使用DefaultShiroFilterChainDefinition来配置过滤规则

使用shiro控制权限,配置filterChainDefinitions结合数据库校验权限。

Filter Name   Class説明
anon                  org.apache.shiro.web.filter.authc.AnonymousFilter任何人都可以访问
authcorg.apache.shiro.web.filter.authc.FormAuthenticationFilter必须是登录之后才能进行访问,不包括remember me
authcBasicorg.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter 
logout org.apache.shiro.web.filter.authc.LogoutFilter 
noSessionCreationorg.apache.shiro.web.filter.session.NoSessionCreationFilter 
perms org.apache.shiro.web.filter.authz.PermissionsAuthorizationFilter指定过滤规则,这个一般是扩展使用,不会使用原生的
portorg.apache.shiro.web.filter.authz.PortFilter 
rest                    org.apache.shiro.web.filter.authz.HttpMethodPermissionFilter 
roles org.apache.shiro.web.filter.authz.RolesAuthorizationFilter 
ssl org.apache.shiro.web.filter.authz.SslFilter 
user org.apache.shiro.web.filter.authc.UserFilter登录用户才可以访问,包含remember me

image.png

  • anno,任何人都可以访问;
  • authc:必须是登录之后才能进行访问,不包括remember me;
  • user:登录用户才可以访问,包含remember me;