본문 바로가기

2021/09

(4)
Spring Security - AnonymousAuthenticationFilter란 - AnonymousAuthenticationFilter 란 - 스프링 시큐리티에서 AnonymousAuthenticationFilter는 익명 사용자의 요청에 대해 처리해주는 필터로 인증을 하지 않은 요청인 경우 인증 객체를 익명 권한이 들어가 있는 객체를 만들어 SecurityContextHolder에 넣어 주는 역할을 한다. 기본적으로 스프링 시큐리티 필터에 포함이 되어 있는 필터이며 만들어지는 객체는 아래와 같은 값을 가지고 있다. pricial : anonymousUser authorities : ROLE_ANONYMOUS // 기본 생성자 public AnonymousAuthenticationFilter(String key) { this(key, "anonymousUser", Authority..
Spring Security - RememberMeAuthenticationFilter 란 - RememberMeAuthenticationFilter 란 - 스프링 시큐리티에서는 RememberMe라는 기능을 지원해준다. 이 RememberMe라는 기능은 세션이 만료된 뒤에도 서버에서 클라이언트의 인증 값을 기억하고 있어 주는 기능이다. 보통 cookie에 Remember Me 기능을 해줄 수 있는 특정한 쿠키 키-값을 세팅해서 구현을 한다. 이 복잡한 과정을 시큐리티에서는 간단한 설정으로 제공을 해주며 해당 기능을 사용하기 위해서는 해당 기능을 아래와 같은 형태로 활성화시켜야 한다. @Override protected void configure(HttpSecurity http) throws Exception { http.formLogin(); http.rememberMe(); } 위와 같이 ..
Spring Security - LogoutFilter 란 - LogoutFilter 란- LogoutFilter란 로그아웃에 대한 처리를 담당하는 필터로 사용자가 로그아웃 요청을 했을 경우에만 적용되는 필터이다. LogoutFilter는 세션 무효화, 인증 토큰 삭제, SecurityContext에서 해당 토큰 삭제, 쿠키 삭제 및 로그인 페이지로 리다이렉트를 시켜주는 기능이 있다. LogoutFilter의 필터 기능이 구현된 코드를 보면 아래와 같다. private void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { if (this.requiresLogout(request, res..
Spring Security - UsernamePasswordAuthenticationFilter 란 - UsernamePasswordAuthenticationFilter 란- UsernamePasswordAuthenticationFilter란 Form based Authentication 방식으로 인증을 진행할 때 아이디, 패스워드 데이터를 파싱하여 인증 요청을 위임하는 필터이다. 쉽게 설명하자면 유저가 로그인 창에서 Login을 시도할 때 보내지는 요청에서 아이디(username)와 패스워드(password) 데이터를 가져온 후 인증을 위한 토큰을 생성 후 인증을 다른 쪽에 위임하는 역할을 하는 필터이다. Spring Boot 기반의 HttpSecurity를 설정하는 코드에서 http.formLogin(); 을 사용하면 시큐리티에서는 기본적으로 UsernamePasswordAuthenticationF..