-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(jwtManager): jwt 토큰에 만료 시간을 추가 * refactor: 로그인 시 참가자의 이름을 같이 반환하도록 변경 * feat: path 경로 수정 및 로그아웃 api 추가 * chore: 토큰 만료시간 추가 * chore: 서브모듈 업데이트 반영 - JWT 토큰 만료 시간 추가 * refactor(JwtCookieManager): 쿠키 생성의 책임을 컨트롤러에서 분리 * refactor(MeetingController): 약속 최초 생성시 주최자에 대한 JWT 토큰을 쿠키로 전송하도록 변경 * style(JwtManager): 생성자 매개변수 팀 컨벤션 개행 적용 * refactor: 쿠키 관련 상수 명 설정 * refactor(JwtCookieManager): 클래스 이름을 CookieManager 로 변경 * refactor(CookieManager): SAME SITE 상수 명을 변경하여 의미를 개선 * refactor(JwtProperties): JWT 관련 환경 변수들을 POJO로 관리하도록 개선 * chore: 서브모듈 업데이트 반영 * refactor(JwtProperties): expirationPeriod 필드 NotNull 검증 추가 * refactor: ConfigurationPropertiesScan을 사용하여 전역으로 관리하도록 변경 * refactor(CookieManager): 클래스의 책임에 맞도록 상수 및 변수 이동
- Loading branch information
1 parent
8ac3259
commit f970575
Showing
16 changed files
with
183 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
backend/src/main/java/kr/momo/controller/CookieManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package kr.momo.controller; | ||
|
||
import org.springframework.http.ResponseCookie; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class CookieManager { | ||
|
||
private static final String ACCESS_TOKEN = "ACCESS_TOKEN"; | ||
private static final String SAME_SITE_OPTION = "None"; | ||
private static final long SESSION_COOKIE_AGE = -1; | ||
private static final long EXPIRED_COOKIE_AGE = 0; | ||
|
||
public String createNewCookie(String value, String path) { | ||
return createCookie(value, path, SESSION_COOKIE_AGE); | ||
} | ||
|
||
public String createExpiredCookie(String path) { | ||
return createCookie("", path, EXPIRED_COOKIE_AGE); | ||
} | ||
|
||
private String createCookie(String value, String path, long maxAge) { | ||
return ResponseCookie.from(ACCESS_TOKEN, value) | ||
.httpOnly(true) | ||
.secure(true) | ||
.path(path) | ||
.sameSite(SAME_SITE_OPTION) | ||
.maxAge(maxAge) | ||
.build() | ||
.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/kr/momo/service/attendee/dto/AttendeeLoginResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package kr.momo.service.attendee.dto; | ||
|
||
import kr.momo.domain.attendee.Attendee; | ||
|
||
public record AttendeeLoginResponse(String token, String name) { | ||
|
||
public static AttendeeLoginResponse from(String token, Attendee attendee) { | ||
return new AttendeeLoginResponse(token, attendee.name()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/kr/momo/service/auth/JwtProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package kr.momo.service.auth; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.time.Duration; | ||
import java.time.temporal.ChronoUnit; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.convert.DurationUnit; | ||
import org.springframework.validation.annotation.Validated; | ||
|
||
@Getter | ||
@Validated | ||
@RequiredArgsConstructor | ||
@ConfigurationProperties("security.jwt") | ||
public class JwtProperties { | ||
|
||
@NotNull | ||
private final String secretKey; | ||
|
||
@NotNull | ||
@DurationUnit(ChronoUnit.HOURS) | ||
private final Duration expirationPeriod; | ||
|
||
public long getExpirationPeriodInMillis() { | ||
return getExpirationPeriod().toMillis(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/kr/momo/service/meeting/dto/MeetingCreateResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package kr.momo.service.meeting.dto; | ||
|
||
import kr.momo.domain.attendee.Attendee; | ||
import kr.momo.domain.meeting.Meeting; | ||
|
||
public record MeetingCreateResponse(String uuid, String name, String token) { | ||
|
||
public static MeetingCreateResponse from(Meeting meeting, Attendee attendee, String token) { | ||
return new MeetingCreateResponse(meeting.getUuid(), attendee.name(), token); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,5 @@ spring: | |
|
||
security: | ||
jwt: | ||
secret_key: ${random.value}" | ||
secret-key: ${random.value}" | ||
expiration-period: 1h |
Submodule security
updated
from 67202e to 61d224
Oops, something went wrong.