아마도이 질문에 대답하기 조금 늦었 겠지만 누구나 유용 할 수 있습니다. configure()
방법에서
는 예를 들어,
logout()
호출을 누락되었습니다
는
http.authorizeRequests()
.anyRequest().fullyAuthenticated()
.and()
.httpBasic()
.and()
.logout() // This is missing and is important
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login");
또한 당신은 당신의 자신의 로그인 페이지 구성 할 수 있습니다
http.authorizeRequests()
// this allows the root and resources to be available without logging in
.antMatchers("/", "/resources/**").permitAll()
// any other type of request will need the credentials
.anyRequest().authenticated()
.and()
// uses the custom login form
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/home") // redirect to home page
.failureUrl("/login?error") // redirect to error page
.permitAll()
.and()
// logout and redirect to login page
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login");
을 당신은 ('.logout을 제공하지 않습니다)' ; 예를 들어 https://spring.io/guides/gs/securing-web/. 어떤 요청을 하시겠습니까? – jonrsharpe
실제로 추가하려고했습니다. 로그 아웃(); 내가 본 여러 가지 예에서 보았지만 아무런 효과가 없습니다. 위의 예제를 변경하여 로그 아웃을 사용하도록 설정하는 것이 좋습니다. 내가하고있는 요청은 "/ logout"에 대한 GET 요청입니다. – simbro
그래, 구성이 확실히 호출되고 있습니다. ".logout.permitAll()"을 추가했습니다. POST 메서드를 사용하여 "/ logout"및 여전히 동일한 메시지를 기록하고 로그 아웃하지 않았습니다. 다른 사람들이 구성 방법으로 사용하는 것은 무엇입니까? – simbro