Skip to content

Commit

Permalink
Merge pull request #183 from APPS-sookmyung/dev
Browse files Browse the repository at this point in the history
[Fix] cors 수정
  • Loading branch information
ajung7038 authored Dec 24, 2024
2 parents 91075e2 + 054fe1a commit 3ce9867
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
22 changes: 0 additions & 22 deletions src/main/java/WELLET/welletServer/config/CorsMvcConfig.java

This file was deleted.

3 changes: 2 additions & 1 deletion src/main/java/WELLET/welletServer/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(request -> {
request.requestMatchers(
// antMatcher("/health")
antMatcher("/health"),
antMatcher("/login"),
antMatcher("/home"),
antMatcher("/**")
).permitAll()
.anyRequest().authenticated();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@ public String callback(@RequestParam("code") String code, HttpServletResponse re
String jwtToken = jwtService.generateToken(member); // 생성된 또는 업데이트된 사용자로 JWT 생성
//
//// // 5. 쿠키에 JWT 저장
// Cookie jwtCookie = new Cookie("jwtToken", jwtToken);
// jwtCookie.setHttpOnly(true); // JavaScript로 쿠키에 접근 불가
// jwtCookie.setSecure(false); // HTTPS에서만 전송
// jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정
// jwtCookie.setPath("/"); // 쿠키를 모든 경로에 적용
//
Cookie jwtCookie = new Cookie("jwtToken", jwtToken);
jwtCookie.setHttpOnly(true); // JavaScript로 쿠키에 접근 불가
jwtCookie.setSecure(true); // HTTPS에서만 전송
jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정
jwtCookie.setPath("/"); // 쿠키를 모든 경로에 적용

// jwtCookie.setDomain(frontendUrl);
// response.addCookie(jwtCookie);

ResponseCookie jwtCookie = ResponseCookie.from("jwtToken", jwtToken)
.httpOnly(true)
.secure(true)
.path("/")
.sameSite("None")
.maxAge(60 * 60 * 24)
.build();
response.addHeader(HttpHeaders.SET_COOKIE, jwtCookie.toString());
response.addCookie(jwtCookie);

// ResponseCookie jwtCookie = ResponseCookie.from("jwtToken", jwtToken)
// .httpOnly(true)
//// .secure(true)
// .path("/")
// .sameSite("None")
// .maxAge(60 * 60 * 24)
// .build();
// response.addHeader(HttpHeaders.SET_COOKIE, jwtCookie.toString());


// 리다이렉트 URL 설정
Expand Down

0 comments on commit 3ce9867

Please sign in to comment.