|
1 | 1 | package com.back.global.security; |
2 | 2 |
|
| 3 | +import org.springframework.beans.factory.annotation.Value; |
3 | 4 | import org.springframework.context.annotation.Bean; |
4 | 5 | import org.springframework.context.annotation.Configuration; |
5 | 6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
18 | 19 | @EnableWebSecurity |
19 | 20 | public class SecurityConfig { |
20 | 21 |
|
| 22 | + @Value("${custom.site.frontUrl}") |
| 23 | + private String frontUrl; |
| 24 | + |
| 25 | + @Value("${custom.site.backUrl}") |
| 26 | + private String backUrl; |
| 27 | + |
21 | 28 | private final CustomOAuth2UserService customOAuth2UserService; |
22 | 29 | private final CustomOAuth2LoginSuccessHandler oauth2SuccessHandler; |
23 | 30 | private final CustomOAuth2LoginFailureHandler oauth2FailureHandler; |
@@ -46,18 +53,16 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { |
46 | 53 | .authorizeHttpRequests(auth -> auth |
47 | 54 | .requestMatchers("/").permitAll() |
48 | 55 | .requestMatchers("/h2-console/**").permitAll() |
| 56 | + .requestMatchers("/actuator/**").permitAll() |
49 | 57 | .requestMatchers("/oauth2/**").permitAll() |
50 | 58 | .requestMatchers("/login/oauth2/**").permitAll() |
51 | 59 | .requestMatchers("/swagger-ui/**", "/api-docs/**").permitAll() |
52 | | - .requestMatchers("/api/user/**").permitAll() |
53 | | - .requestMatchers("/api/cocktail/**").permitAll() |
54 | | - .requestMatchers("/api/chatbot/**").permitAll() |
55 | | - .requestMatchers("/api/cocktails/**").permitAll() |
56 | | - |
| 60 | + .requestMatchers("/user/**").permitAll() |
| 61 | + .requestMatchers("/cocktails/**").permitAll() |
| 62 | + .requestMatchers("/chatbot/**").permitAll() |
57 | 63 |
|
58 | 64 | // 회원 or 인증된 사용자만 가능 |
59 | | - .requestMatchers("/api/admin/**").hasRole("ADMIN") |
60 | | -// .requestMatchers("/api/cocktail/detail~~").authenticated() |
| 65 | + .requestMatchers("/admin/**").hasRole("ADMIN") |
61 | 66 |
|
62 | 67 | //그 외에는 인증해야함 |
63 | 68 | .anyRequest().authenticated() |
@@ -95,9 +100,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { |
95 | 100 | public CorsConfigurationSource corsConfigurationSource() { |
96 | 101 | CorsConfiguration configuration = new CorsConfiguration(); |
97 | 102 | configuration.setAllowedOrigins(Arrays.asList( |
98 | | - "http://localhost:3000", |
99 | | - "http://localhost:8080" |
100 | | - //나중에 운영환경 추가 |
| 103 | + frontUrl, |
| 104 | + backUrl |
101 | 105 | )); |
102 | 106 | configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")); |
103 | 107 | configuration.setAllowedHeaders(Arrays.asList("*")); |
|
0 commit comments