AnonymousAuthenticationFilter는 인증 정보가 존재하지 않을 때, 익명 사용자임을 명시해주기 위해 익명 사용자 정보를 SecurityContext에 저장해주기 위해 동작하는 필터다.
SecurityContextholder.getContext().getAuthentication() 를 통해서 인증 정보를 가져오고 존재하지 않을 시에 다음과 같이 익명 사용자 authentication을 생성한다.
여기서 key, principal, authorities는 AnonymousAuthenticationFilter가 생성될 때 생성자를 통해서 다음과 같이 지정된다.
이렇게 사용자가 인증을 받지 않았다고 인증 정보를 null로 다루기보다는 인증 정보가 없는 익명 사용자라는 정보를 가진 authentication을 사용하게 된다.