@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
// CORS 및 CSRF 설정
httpSecurity.cors().and().csrf().disable();
// API 권한 설정
configureApiAuthorization(httpSecurity);
// OAuth2 로그인 설정 추가
httpSecurity.oauth2Login(oauth2 -> oauth2
.loginPage("/login") // 사용자 정의 로그인 페이지 (필요 시)
.defaultSuccessUrl("/home", true) // 로그인 성공 후 리디렉션 URL
.failureUrl("/login?error=true") // 로그인 실패 시 리디렉션 URL
.successHandler(customAuthenticationSuccessHandler()) // 커스텀 성공 핸들러
.failureHandler(customAuthenticationFailureHandler()) // 커스텀 실패 핸들러
);
return httpSecurity.build();
}
이건 나의 SecurityConfig.java 코드이다.
Rest API기반 애플리케이션으로, CSRF 보호는 비활성화하였다.
@SpringBootApplication 중 3 가지 (1) | 2024.12.25 |
---|---|
트랜잭션 격리수준 (1) | 2024.12.18 |
@Controller @Service @Repository 차이 및 의존성 주입 (0) | 2024.12.18 |