May 2015
Intermediate to advanced
234 pages
4h 18m
English
In this recipe, you'll learn how to add a URL /logout to let the user log out.
In the SecurityConfig class, in the configure() method, call the logout() method and the logoutRequestMatcher() method to declare a logout URL:
protected void configure(HttpSecurity http) throws Exception {
...
AntPathRequestMatcher pathRequestMatcher = new AntPathRequestMatcher("/logout");
http.logout().logoutRequestMatcher(pathRequestMatcher);
}Use org.springframework.security.web.util.
matcher
.AntPathRequestMatcher, and not the deprecated org.springframework.security.web.util.AntPathRequestMatcher class.
While going to the URL /logout, the user will be logged out.
Read now
Unlock full access