• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    해결됨

favicon 요청시 리다이렉트

20.04.30 22:04 작성 조회수 231

0

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/").permitAll()
                .anyRequest().authenticated();
        http.formLogin();
        http.httpBasic();
    }
}

SecurityConfig 설정파일입니다.

localhost:8080 으로 들어갈 때 favicon도 같이 요청하는데 favicon은 인증이 필요하기 때문에
login도 요청하는데요. 이 시점에 화면이 index.html입니다.
favicon으로 인해 login을 요청했기 때문에 login 페이지를 보여줘야 하는거 아닌가요?

"/" 요청이 permitAll 이라서 일단 "/" 요청에 대한 응답이 나가고 favicon 요청으로 인한 login 페이지는 무시되는건가요?

답변 2

·

답변을 작성해보세요.

1

네 말씀하신게 맞습니다. 웹브라우저에 개발자 도구 열어서 보시면 login 요청도 발생했을 겁니다. 그래서 favicon.ico 같은 요청은 인증 필터를 적용하지 않도록 추가로 설정해주시는게 좋습니다.

@Override
public void configure(WebSecurity web) {
web.ignoring()
.requestMatchers(PathRequest.toStaticResources().atCommonLocations());
}

이런식으로요.

0

mingi.kang님의 프로필

mingi.kang

질문자

2020.05.01

답변 감사드립니다!!