There are two ways of achieving logout
1. Implement your own Logout method in the normal action, take the subject, and then logout
This needs to be configured in Shirofilterfactorybean filterchaindefinitions
The URL of the corresponding action is anon
<property name= "Filterchaindefinitions" >
<value>
# Some example chain definitions:
/index.htm = Anon
/logout = Anon
/unauthed = Anon
/console/** = Anon
/css/** = Anon
/js/** = Anon
/lib/** = Anon
/admin/** = authc, roles[admin]
/docs/** = authc, Perms[document:read]
/** = authc
# More Url-to-filterchain definitions here
</value>
2. Using the logout filter provided by the Shiro
Need to define the appropriate bean
<bean id= "Logout" class= "Org.apache.shiro.web.filter.authc.LogoutFilter" >
<property name= "RedirectURL" value= "/loginform"/>
</bean>
Then configure the corresponding URL filter to logout as follows
<property name= "Filterchaindefinitions" >
<value>
# Some example chain definitions:
/index.htm = Anon
/logout = Logout
/unauthed = Anon
/console/** = Anon
/css/** = Anon
/js/** = Anon
/lib/** = Anon
/admin/** = authc, roles[admin]
/docs/** = authc, Perms[document:read]
/** = authc
# More Url-to-filterchain definitions here
</value>
Note: Anon,authcbasic,auchc,user is an authentication filter, Perms,roles,ssl,rest,port is an authorization filter
About customizing the filter
My Shiro Tour: Three talking about the filter of ShiroCategory: Shiro | Tags: Shiro | Author: Lhacker Related | Release Date: 2014-11-29 | Heat: 63°
The previous period of time is lazy, the project is also somewhat tight, did not write anything. Now do some tidying up on Shiro. The previous article mainly introduces a complete and simple example of Shiro integration into the project, mainly the spring project. This article, want to talk about Shiro filter, which requires the reader to Shiro have a certain understanding, at least useful shiro.
01 |
<bean id= "Shirofilter" class= "Org.apache.shiro.spring.web.ShiroFilterFactoryBean" > |
02 |
<property name= "SecurityManager" ref= "SecurityManager"/> |