private static final List<String> EXCLUDE_URL =
Collections.unmodifiableList(
Arrays.asList(
"/signup/**",
"/api/member",
"/authenticate"
));
...
...
...
@Override
protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
return EXCLUDE_URL.stream().anyMatch(exclude -> exclude.equalsIgnoreCase(request.getServletPath()));
}
sholudNotFilter 메서드를 사용하여 EXCLUDE_URL 리스트에 제외시킬 URL을 추가하면 추가한 URL을 제외시킨다고 하는데 결론은 제외시키지 못했다. 아래코드는 WebSecurityConfig의 configure 부분이다.
@Override
public void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests().antMatchers("/authenticate", "/api/member").permitAll()
.anyRequest().authenticated()
.and()
.exceptionHandling()
.authenticationEntryPoint(jwtAuthenticationEntryPoint)
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
}
http.addFilterBefor(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class) 를 통해서
jwtRequestFilter가 지정된 필터 "UsernamePasswordAuthenticationFilter"보다 먼저 실행된다
= 일반적이라고 생각하는 아이디, 패스워드를 이용한 인증을 담당하는 필터
Configure의 antMatchers에 제외시킬 URL을 적어주면 인증절차를 거치지 않고 해당URL이 실행되지만
Exclude_URL은 왜 제외가 되지않는지 조금 더 찾아봐야겠다.
->
Exclude_URL 에서 제외시킨 URL은 JwtRequestFilter 내부에서 예외처리 되어서
id나 password check 등 유효성 검사에서 예외처리를 하지않고 넘어간다.
'Vue > Vue' 카테고리의 다른 글
(signUp-3) 회원가입 마무리 (0) | 2021.12.25 |
---|---|
(signup-2) 중복확인 (0) | 2021.12.24 |
(SignUp-1) 회원가입 구현하기 (0) | 2021.12.16 |
(Login-3) axios 인터셉터 사용하기 (0) | 2021.12.15 |
(Login-2) 로그인 인증, 인증 만료 (0) | 2021.12.10 |