Security Filter 설정에서 permitAll() 에러

Sol's·2023년 1월 23일
0

오류

목록 보기
15/18

view 페이지 작업을 시작하여 간단한 테스트 Controller를 만들고 view를 띄워보았습니다.
그런데 이상하게 error 페이지로 넘어가는 것이였습니다.

Security Filter에서는 해당 URL을 permitAll로 설정해 두었습니다.

controller

@Controller
@RequestMapping(value = "/hello")
public class HelloController {

    //타임리프 테스트
    @RequestMapping(value = "/response/hello")
    public String responseViewV3(Model model) {
        model.addAttribute("data", "hello!!");
        return "response/hello";
    }
}

SecurityConfig

 .antMatchers("/hello/**").permitAll()

해당 URL로 접근시 JSON형태로 에러가 반환되는 형상 발생...

콘솔에 찍힌 내용

왜 이렇게 넘어가는지 이유를 모르겠어서

filterChain에서 authorization이 null이거나 Bearer가 아닐경우 doFilter로 넘겨주었더니 통과하였습니다.

//token 안보냈다면 null이라면 권한부여하지 않고 리턴한다.
        if (authorization == null || !authorization.startsWith("Bearer ")) {
            log.error("authorization을 잘못보냈습니다.");
            filterChain.doFilter(request,response);
            return;
        }

profile
배우고, 생각하고, 행동해라

0개의 댓글