본문 바로가기

SpringBoot/SpringSecurity3

리소스 접근 시 인증,인가 Exception 처리 특정 자원 접근 시 발생하는 있는 거절 종류 ( 토큰은 정상 ) - 로그인조차 되지 않은 채 로그인이 필요한 리소스에 접근 시 AuthenticationException -> 인증 실패 - 로그인하였으나 권한 없는 관계로 인한 AccessDeniedException -> 인가 실패 *로그인 은 정상 토큰으로 인증객체 생성 완료된 상태 *비로그인 은 Anonymous인증객체가 생성 완료된 상태 더보기 각각 어떤 식으로 에러 응답을 처리할까? 인가 실패 CustomAccessDeniedHandler 권한 없는 자원 접근 발생하는 예외( AccessDeniedException )에 대하여 AccessDeinedHandler 인터페이스를 구현하여 처리 @Slf4j public class CustomAccessD.. 2023. 10. 19.
JwtAuthenticationFilter 내 발생 가능한 Exception 공통 처리 JwtAuthenticationFilter 인증 필터 내 검증되는 부분은 두 종류가 존재한다. 1. ID 존재 여부 2. 비밀번호 일치 여부 두 종류의 검증에 대해 거절 상황 시 하나의 로직으로 응답할 수 있는 방법이 필요하였다.... 인증처리 시 Exception 처리 부분을 먼저 확인해본다. 인증 처리하는 Filter 일부분 1. Authentication authenticationResult = attemptAuthentication(request, response); attemptAuthentication 메소드를 통하여 ID, 패스워드 등 인증한다. 이 때, ID 및 비밀번호 검증 실패 시 AuthenticationException 을 던지게 된다. 2.catch (AuthenticationEx.. 2023. 10. 19.
[이슈] AuthenticationProvider 인터페이스 구현 후 적용되지 않는 상황 처리 SpringSecurityConfig 파일 @Configuration @RequiredArgsConstructor @EnableWebSecurity public class SpringSecurityConfig { private final MemberService memberService; private final PasswordEncoder bCryptPasswordEncoder; private final CustomJwtProvider customJwtProvider; private final AuthenticationConfiguration authenticationConfiguration; @Bean public SecurityFilterChain filterChain(HttpSecurity htt.. 2023. 10. 19.