Skip to content

Commit

Permalink
리디렉션 /로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
zoangrak committed Jun 4, 2024
1 parent 053076f commit fc6fc98
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
import org.springframework.security.web.authentication.logout.LogoutFilter;
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
import org.springframework.security.web.savedrequest.RequestCache;
import org.springframework.security.web.savedrequest.RequestCacheAwareFilter;
import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter;

@Configuration
@EnableWebSecurity
Expand Down Expand Up @@ -57,6 +62,10 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.anyRequest().permitAll()
.and()

.exceptionHandling()
.authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/"))
.and()

// 소셜 로그인 설정
.oauth2Login()
.successHandler(oAuth2LoginSuccessHandler) // 동의하고 계속하기를 눌렀을 때 핸들러
Expand All @@ -65,7 +74,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

http.addFilterAfter(customJsonUsernamePasswordAuthenticationFilter(), LogoutFilter.class);
http.addFilterBefore(jwtAuthenticationProcessingFilter(), CustomJsonUsernamePasswordAuthenticationFilter.class);

http.addFilterBefore(requestCacheAwareFilter(), SecurityContextHolderAwareRequestFilter.class);
return http.build();
}

Expand All @@ -74,6 +83,16 @@ public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}

@Bean
public RequestCache requestCache() {
return new HttpSessionRequestCache();
}

@Bean
public RequestCacheAwareFilter requestCacheAwareFilter() {
return new RequestCacheAwareFilter(requestCache());
}

/**
* AuthenticationManager 설정 후 등록
* PasswordEncoder를 사용하는 AuthenticationProvider 지정 (PasswordEncoder는 위에서 등록한 PasswordEncoder 사용)
Expand Down

0 comments on commit fc6fc98

Please sign in to comment.