Skip to content

Instantly share code, notes, and snippets.

@marcelstoer
Last active March 1, 2016 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelstoer/c9a894a929c8fe38222a to your computer and use it in GitHub Desktop.
Save marcelstoer/c9a894a929c8fe38222a to your computer and use it in GitHub Desktop.
Spring Security logout without CSRF protection
...
<!-- http://docs.spring.io/spring-security/site/docs/4.0.x/reference/htmlsingle/#filter-stack -->
<!-- logout w/o CSRF protection if logout filter is placed before the CSRF filter -->
<security:custom-filter before="CSRF_FILTER" ref="logoutFilter" />
</security:http>
<bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
<constructor-arg name="logoutSuccessUrl" value="place-whatever-you-need-here" />
<constructor-arg name="handlers">
<list>
<!-- no need to add org.springframework.security.web.csrf.CsrfLogoutHandler -->
<bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>
</list>
</constructor-arg>
<!-- default logout URL /logout is applied internally -->
</bean>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment