Skip to content

Commit

Permalink
Merge pull request #153 from swm-nodriversomabus/FIX-Login-Page-Url
Browse files Browse the repository at this point in the history
fix(BE): login page로 redirect 대신 401에러로 대체 #114
  • Loading branch information
Lemonade255 authored Oct 24, 2023
2 parents 504e636 + 7f27d8a commit a3da8af
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.oauth2.client.web.OAuth2LoginAuthenticationFilter;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
Expand Down Expand Up @@ -69,7 +71,7 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti
.baseUri("/oauth2/authorization")
.authorizationRequestRepository(oAuth2AuthorizationRequestBasedOnCookieRepository)
);
oauth2.loginPage(loginPage);
// oauth2.loginPage();
oauth2.redirectionEndpoint(redirectionEndpointConfig -> redirectionEndpointConfig.baseUri("/*/oauth2/code/*"));
oauth2.userInfoEndpoint( // oauth2 로그인 시 사용자 정보를 가져오는 엔드포인트와 사용자 서비스 설정
userInfoEndpointConfig ->
Expand All @@ -78,6 +80,11 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti
oauth2.failureHandler(oAuth2LoginFailureHandler);//핸들러
oauth2.successHandler(oAUth2LoginSuccessHandler);
});
httpSecurity.exceptionHandling(
exceptionHandling -> exceptionHandling.authenticationEntryPoint(
new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)
)
);
httpSecurity.logout(
logout ->
logout
Expand Down

0 comments on commit a3da8af

Please sign in to comment.