security:
oauth2.client:
registration:
kakao:
clientId:
clientSecret:
clientAuthenticationMethod: client_secret_post
authorizationGrantType: authorization_code
redirectUri: "{baseUrl}/{action}/oauth2/code/{registrationId}"
oauth2:
authorizedRedirectUris:
- https://j10d109.p.ssafy.io/api/oauth/kakao/callback
- https://j10d109.p.ssafy.io/oauth/kakao/callback
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
System.out.println("securityFilterChain");
log.info("securityFilterChain start");
try {
http.cors(AbstractHttpConfigurer::disable);
http.sessionManagement((sessionManagement)->sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
http.csrf(AbstractHttpConfigurer::disable);
http.formLogin(AbstractHttpConfigurer::disable);
http.httpBasic(AbstractHttpConfigurer::disable);
http.exceptionHandling((exceptionHandling)->exceptionHandling.authenticationEntryPoint(new RestAuthenticationEntryPoint()).accessDeniedHandler(tokenAccessDeniedHandler));
http.authorizeHttpRequests(authorize -> authorize.requestMatchers(CorsUtils::isPreFlightRequest).permitAll().requestMatchers("/swagger-ui/**", "/v3/**", "/api/**", "/swagger-resources/**").permitAll().anyRequest().authenticated());
http.oauth2Login(oauth2 -> oauth2.authorizationEndpoint(authorization -> authorization.baseUri("/oauth2/authorization").authorizationRequestRepository(oAuth2AuthorizationRequestBasedOnCookieRepository()))
.redirectionEndpoint(redirection -> redirection.baseUri("/*/oauth2/code/*"))
.userInfoEndpoint(userInfo -> userInfo.userService(oAuth2UserService))
.successHandler(oAuth2AuthenticationSuccessHandler())
.failureHandler(oAuth2AuthenticationFailureHandler()));
http.addFilterBefore(tokenAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
log.info("securityFilterChain succeess");
} catch (Exception e) {
log.error("error : securityFilterChain", e);
}
return http.getOrBuild();
}
코드를 어디까지 첨부해야 할 지 몰라 일단, 관련 문제인 것 같은 것들을 올립니다.
로컬에서는 잘 되던 것이, 배포만 하면 404가 출력됩니다.