Skip to content

Commit

Permalink
Merge pull request #61 from devocean-finut/dev/level_test
Browse files Browse the repository at this point in the history
#60 Fix formLogin : formLogin λΉ„ν™œμ„±ν™”
  • Loading branch information
plum-king authored Nov 14, 2024
2 parents 8f0027c + ba1079f commit b16d9c8
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions src/main/java/com/finut/finut_server/config/SecurityConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.finut.finut_server.config;


import com.finut.finut_server.apiPayload.exception.handler.CustomOAuth2AuthenticationSuccessHandler;
import com.finut.finut_server.config.auth.CustomOAuth2UserService;
import com.finut.finut_server.domain.user.UsersRepository;
Expand All @@ -10,13 +9,9 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.oauth2.client.InMemoryOAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
Expand All @@ -43,28 +38,11 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http, CustomOAuth2Us
)
.defaultSuccessUrl("/success", true)
)
.formLogin(formLogin ->
formLogin
.defaultSuccessUrl("/success", true)
)
.logout(logout ->
logout
.logoutSuccessUrl("/") // μž„μ‹œ
)
.csrf(AbstractHttpConfigurer::disable) // post μš”μ²­μ„ μœ„ν•œ csrf disable
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
.headers(headers -> headers.frameOptions(frameOptions -> frameOptions.sameOrigin()));
return http.build();
}

@Bean
public UserDetailsService userDetailsService() {
UserDetails user = User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
return http.build();
}

@Bean
Expand All @@ -83,7 +61,7 @@ public CustomOAuth2UserService customOAuth2UserService(UsersRepository userRepos
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("http://localhost:3000")); // ν”„λ‘ νŠΈμ—”λ“œ 도메인
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD")); // ν—ˆμš©ν•  HTTP λ©”μ„œλ“œ
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD")); // ν—ˆμš©ν•  HTTP λ©”μ„œλ“œ
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type")); // ν—ˆμš©ν•  헀더
configuration.setExposedHeaders(Arrays.asList("Authorization")); // μ‘λ‹΅μ—μ„œ λ…ΈμΆœν•  헀더
configuration.setAllowCredentials(true); // 자격 증λͺ… 포함 μš”μ²­ ν—ˆμš©
Expand Down

0 comments on commit b16d9c8

Please sign in to comment.