인증(4)
-
Spring Security - 인증, 인가 예외 ExceptionTranslationFilter, AuthenticationException, AccessDeniedException
ExceptionTranslationFilter Spring Security는 두 가지 예외를 다룬다. AuthenticationException - 인증 예외, 인증에 실패할 경우 발생 AccessDeniedException - 인가 예외, 인가에 실패할 경우 발생 사용 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 protected void configure(HttpSecurity http) throws Exception { http.exceptionHandling() .authenticationEntryPoint(new AuthenticationEntryPoint() { @Override public void commence(HttpServletRequest htt..
2021.04.16 -
Spring Security - 익명 사용자 인증, AnonymousAuthenticationFilter
AnonymousAuthenticationFilter 플로우 Spring Security는 인증을 받지않은 사용자도 익명 사용자 인증객체를 생성하여 관리한다. AnonymousAuthenticationFilter는 인증 객체가 SecurityContext에 존재하지 않는 경우 AnonymousAuthenticationToken을 생성하고 SecurityContext에 저장한다. 이렇게 SecurityContext에서 관리가 되면, 후에 isAnonymous()와 isAuthenticated()로 인증 사용자와 익명 사용자를 구분할 수 있게된다. 익명 인증객체를 세션에 저장하지는 않는다.
2021.04.15 -
SPRING SEQURITY - Form Login 인증 흐름, AuthenticationFilter
로그인 요청을 한다. AuthenticationFilter가 요청을 받아, RequestMatcher를 생성해 요청 정보가 매칭되는지 확인한다. 요청정보가 매칭된다면 인증객체(Authentication)을 생성한다. AuthenticationManager에게 인증 객체를 이용해 인증 요청을 하고 AuthenticationManager는 AuthenticationProvider에게 인증 요청을 위임한다. AuthenticationProvider는 인증 객체를 분석하여 username, password를 보고 인증 성공 여부를 판단한다. 인증이 성공되면 AuthenticationManager는 인증객체를 새로 생성한다. 이 때, 인증객체는 사용자 정보와, 권한 정보를 가진다. 해당 인증객체를 Security..
2021.04.15 -
SPRING SEQURITY - Form Login 인증 API
사용 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 package io.security.basicsecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfig..
2021.04.15