How to configure Shiro logout in spring

Source: Internet
Author: User
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"/>
03 <

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.