Customize the jump address after Shiro logout
1. Modify the LogoutFilter redirect address
LogoutFilter logout=new LogoutFilter();
logout.setRedirectUrl(Contants.MANAGE_PREFIX+"/login");
2. Modify ShiroFilterFactoryBean’s filters
Map<String,Filter> filters=new HashMap();
filters.put("logout",logout);
shiroFilterFactoryBean.setFilters(filters);
3. Modify the FilterChainDefinitionMap of ShiroFilterFactoryBean
LinkedHashMap<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
filterChainDefinitionMap.put(Contants.MANAGE_PREFIX+"/logout", "logout");
@Bean
public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.setSecurityManager(securityManager);
shiroFilterFactoryBean.setLoginUrl(Contants.MANAGE_PREFIX+"/login");
shiroFilterFactoryBean.setSuccessUrl(Contants.MANAGE_PREFIX+"/index");
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
//Custom Exit Redirection
LogoutFilter logout=new LogoutFilter();
logout.setRedirectUrl(Contants.MANAGE_PREFIX+"/login");
Map<String,Filter> filters=new HashMap();
filters.put("logout",logout);
shiroFilterFactoryBean.setFilters(filters);
LinkedHashMap<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
filterChainDefinitionMap.put("/system.css/**", "anon");
filterChainDefinitionMap.put("/system.js/**", "anon");
filterChainDefinitionMap.put("/system.fonts/**", "anon");
filterChainDefinitionMap.put("/system.img/**", "anon");
filterChainDefinitionMap.put(Contants.MANAGE_PREFIX+"/logout", "logout");
filterChainDefinitionMap.put(Contants.MANAGE_PREFIX+"/**", "authc");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}
See the picture below
Read More:
- [Solved] shiro Error: org.apache.shiro.authc.UnknownAccountException:
- [Solved] SpringMVC Shiro Error: org.apache.shiro.UnavailableSecurityManagerException No SecurityManager
- [Solved] Annotation Customize Error: ElementType cannot be resolved to a variable
- [Solved] jooq Customize GeneratorStrategy Error: ClassNotFoundException
- How to Solve shiro Set sessionIdUrlRewritingEnabled Error (jessionid Removed)
- Springboot integration shiro error: UnsatisfiedDependencyException: Error creating bean with name ‘getShiroFilterFact
- [Solved] shiro Error: SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
- [Solved] Activity jump permission UID Error: ActivityTaskmanager: Permission Denied
- Maven project running servlet jump JSP error: HTTP status 500 – unable to compile class for JSP
- [Solved] Error running ‘myToncat‘: Address localhost:8080 is already in use
- jemter java.net.BindException:Address alreardy in use [How to Solve]
- [Solved] Error: caused by: java.net.bindexception: the address is already in use
- The node requests the API address written by java to report an error error:getaddrinfo ENOTFOUND
- Resin Failed to Startup Error: ERROR: transport error 202: bind failed: Address already in use: JVM_Bind Listenin (Two Resins in One PC)
- [Solved] com.alibaba.druid.filter.FilterManager : load filter error, filter not found : sl4j
- JAVA: How to use the third-party font library method (using the third-party TTF / TTC font library method)
- Redis: How to Implementate LRU Caching Mechanism Manually
- [Solved] Java.util.linkedhashmap cannot be cast to entity class
- Springboot Project Error: Failed to execute goal org.apache.maven.plugins
- Cannot call sendRedirect() after the response has been committed