Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/main/java/com/bamboo/log/common/config/CorsMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ public class CorsMvcConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry corsRegistry) {

corsRegistry.addMapping("/**")
.exposedHeaders("Set-Cookie")
//프론트 url 넣기
.allowedOrigins("http://localhost:3000");
.allowedOrigins("*") // 모든 Origin 허용
.allowedMethods("*") // 모든 HTTP 메서드 허용
.allowedHeaders("*") // 모든 헤더 허용
.allowCredentials(true) // 쿠키 허용
.exposedHeaders("Set-Cookie");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers("/refresh").permitAll()
.requestMatchers("/logout").hasAnyRole("USER")
.requestMatchers("/swagger-ui/**","/v3/api-docs/**","/swagger-resources/**","/webjars/**").permitAll()
.requestMatchers("/api/images/**").hasAnyRole("USER")
.anyRequest().authenticated());
.anyRequest().hasAnyRole("USER"));


http.sessionManagement((session) -> session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public class CustomFailureHandler extends SimpleUrlAuthenticationFailureHandler

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
response.sendRedirect("http://localhost:3000");
response.sendRedirect("http://localhost:3000/login");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
addRefreshEntity(name, username, refreshToken, 1209600000L);
response.addCookie(createCookie("refresh", refreshToken));
response.addCookie(UnScretCreateCookie("access", accessToken));
response.sendRedirect("http://localhost:3000/");
response.sendRedirect("http://localhost:3000/welcome");
}

private Cookie createCookie(String key, String value) {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# application.yml

spring:
datasource:
Expand Down