https://lookids.atlassian.net/jira/software/projects/KAN/boards/3?selectedIssue=KAN-22
AuthenticationProvider
, JwtAuthenticationFilter
제공 받음
CorsFilter (Spring MVC에서 CORS 요청을 처리하기 위한 필터)
config.setAllowCredentials(true)
: 쿠키 및 인증 정보를 포함한 요청을 허용config.addAllowedOriginPattern("*")
: 모든 출처에서의 요청을 허용(필요에 따라 특정 출처로 제한)config.addAllowedHeader("*")
: 모든 헤더를 허용 ← 보안상의 이유로 실제 배포 환경에서는 신뢰할 수 있는 출처만 허용하는 것이 좋음config.addAllowedMethod("*")
: 모든 HTTP 메서드(GET, POST 등)를 허용config.setExposedHeaders(List.of("Authorization"))
: 클라이언트가 접근할 수 있는 응답 헤더를 설정SecurityFilterChain
authenticationProvider
를 설정ProviderManager
를 사용하여 여러 AuthenticationProvider
를 조합. 여기서는 DaoAuthenticationProvider
와 커스텀 OAuthAuthenticationProvider
를 사용
DaoAuthenticationProvider
는 사용자 정보를 데이터베이스에서 조회하고 비밀번호를 검증하는 데 사용. UserDetailsService
로 authUserDetailService
를 설정하고, 비밀번호 인코더로 BCryptPasswordEncoder
(BCrypt 해시 함수를 사용하여 비밀번호 암호화)를 설정
AuthUserDetailService
사용자 인증을 위해 필요한 정보를 로드하는 서비스
Spring Security와의 통합을 통해 사용자의 인증 및 권한 부여를 관리. 이 클래스는 사용자 UUID로 데이터베이스에서 사용자 정보를 조회하고, 이를 기반으로 UserDetails
객체를 생성하여 인증 과정에 활용public UserDetails loadUserByUsername(String uuid) throws UsernameNotFoundException {
return new AuthUser(authRepository.findByUuid(uuid).orElseThrow(() -> new UsernameNotFoundException(uuid)));
}
UserDetails
: Spring Security에서 사용자 인증 정보를 나타내는 인터페이스