실전프로젝트 - 인증 프로세스 Ajax 인증 구현

Seung jun Cha·2023년 1월 3일
0
  • 비동기 인증방식의 개요로 동기방식으로 진행하는 Form방식과 진행방식이 크게 다르지 않다.
    AntPathRequestMatcher 는 AntPathRequestMatcher 에 설정한 자원정보와 클라이언트가 요청한 자원정보를 서로 비교해서 참인지 거짓인지 알려주는 기능을 하는 클래스
  1. AbstractAuthenticationProcessingFilter를 extends
    Ajax로 인증을 시도할 경우 request의 Header에 특정 값을 넣어서 보내기로 합의한다.
    요청 Url과 Header값을 검증하는 로직이다.
  protected AjaxLoginProcessingFilter() {
        super(new AntPathRequestMatcher("/api/login"));
    }

    private boolean isAjax(HttpServletRequest request) {
        if ("XMLHttpRequest".equals(request.getHeader("X-Requested-with"))){
            return true;
        }
        return false;
    }

0개의 댓글