-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 클래스명 변경 * refactor: DTO 분리 * refactor: 쿠키 설정 추가 * refactor: 메서드명 변경 * refactor: 인증 플로우 변경 * refactor: DTO 타입 변경 * refactor: 변수명 변경 * feature: 봉달목록에 상품 추가 api (#31) * feat: CartProduct 도메인 추가 * feat: Entity 존재 여부 확인 확장 함수 추가 * feat: CartProduct 저장 로직 추가 * refactor: ProductController 패키지 이동 * feat: CartProduct 저장 API 추가 * test: CartProduct 저장시 예외 상황 테스트 추가 * refactor: 중복된 dependency 제거 * chore: mockk 의존성 추가 * test: 로그인 셋업 메서드 추가 * test: 구현된 Auth 헤더 사용 하도록 CartProduct API 테스트 수정 * refactor: 중복된 dependency 제거 * refactor: Accessor -> LoginMember 네이밍 수정 * test: 검증부 내용 이름 수정 * feat: 회원 존재 유무 검증 로직 추가 * test: application 테스트내 빈 등록 범위 수정 * test: 회원 검증 추가에 따른 테스트 로직 수정 * feat: 상품 수량 값객체 추가 * feat: 봉달 상품 수량 값객체 적용 * test: 잘못된 봉달 상품 수량에 대한 테스트 추가 * refactor: 이미 봉달 목록에 존재하는 상품에 대한 처리 추가 * fix: value 필드 예약어 사용에 의한 오류 해결 * refactor: 클래스명 변경 * refactor: url 변경 * refactor: AccessToken으로만 인증을 수행하게 변경 * feat: 로그인 연장 API 추가 * test: 로그인 연장 테스트 추가 * refactor: GET 메서드로 변경 * test: 로그인 연장 테스트 추가 * test: �shouldNotBeNull() 사용 Co-authored-by: Taeyeon <90550065+TaeyeonRoyce@users.noreply.github.com> * chore: import 정리 * refactor: 사용하지않는 ExceptionType 제거 * refactor: AuthException 패키지 이동 * chore: 서브모듈 업데이트 * chore: shouldNotBeNull 메서드 사용 --------- Co-authored-by: Taeyeon <90550065+TaeyeonRoyce@users.noreply.github.com>
- Loading branch information
1 parent
2617f49
commit 086cc29
Showing
24 changed files
with
403 additions
and
180 deletions.
There are no files selected for viewing
Submodule backend-submodule
updated
from f0d09e to 50c926
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.petqua.application.auth | ||
|
||
data class AuthResponse( | ||
data class AuthTokenInfo( | ||
val accessToken: String, | ||
val refreshToken: String, | ||
) | ||
) |
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
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/petqua/domain/auth/oauth/OauthClientProvider.kt
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
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/petqua/domain/auth/oauth/OauthServerType.kt
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
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/petqua/domain/auth/token/AccessTokenClaims.kt
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
2 changes: 1 addition & 1 deletion
2
...ua/common/exception/auth/AuthException.kt → ...om/petqua/exception/auth/AuthException.kt
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
2 changes: 1 addition & 1 deletion
2
...on/exception/auth/OauthClientException.kt → ...ua/exception/auth/OauthClientException.kt
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
2 changes: 1 addition & 1 deletion
2
...xception/auth/OauthClientExceptionType.kt → ...xception/auth/OauthClientExceptionType.kt
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
74 changes: 74 additions & 0 deletions
74
src/main/kotlin/com/petqua/presentation/auth/AuthController.kt
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,74 @@ | ||
package com.petqua.presentation.auth | ||
|
||
import com.petqua.application.auth.AuthService | ||
import com.petqua.application.auth.AuthTokenInfo | ||
import com.petqua.domain.auth.oauth.OauthServerType | ||
import org.springframework.http.HttpHeaders.AUTHORIZATION | ||
import org.springframework.http.HttpHeaders.SET_COOKIE | ||
import org.springframework.http.HttpStatus.FOUND | ||
import org.springframework.http.ResponseCookie | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.CookieValue | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.RequestHeader | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RequestMapping("/auth") | ||
@RestController | ||
class AuthController( | ||
private val authService: AuthService | ||
) { | ||
|
||
@GetMapping("/{oauthServerType}") | ||
fun redirectToAuthCodeRequestUrl( | ||
@PathVariable oauthServerType: OauthServerType, | ||
): ResponseEntity<Void> { | ||
val redirectUri = authService.getAuthCodeRequestUrl(oauthServerType) | ||
return ResponseEntity.status(FOUND) | ||
.location(redirectUri) | ||
.build() | ||
} | ||
|
||
@GetMapping("/login/{oauthServerType}") | ||
fun login( | ||
@PathVariable oauthServerType: OauthServerType, | ||
@RequestParam("code") code: String, | ||
): ResponseEntity<AuthResponse> { | ||
val authTokenInfo = authService.login(oauthServerType, code) | ||
val refreshTokenCookie = createRefreshTokenCookie(authTokenInfo) | ||
val authResponse = AuthResponse( | ||
accessToken = authTokenInfo.accessToken | ||
) | ||
return ResponseEntity | ||
.ok() | ||
.header(SET_COOKIE, refreshTokenCookie.toString()) | ||
.body(authResponse) | ||
} | ||
|
||
@GetMapping("/token") | ||
fun extendLogin( | ||
@RequestHeader(AUTHORIZATION) accessToken: String, | ||
@CookieValue("refresh-token") refreshToken: String, | ||
): ResponseEntity<AuthResponse> { | ||
val authTokenInfo = authService.extendLogin(accessToken, refreshToken) | ||
val refreshTokenCookie = createRefreshTokenCookie(authTokenInfo) | ||
val authResponse = AuthResponse( | ||
accessToken = authTokenInfo.accessToken | ||
) | ||
return ResponseEntity | ||
.ok() | ||
.header(SET_COOKIE, refreshTokenCookie.toString()) | ||
.body(authResponse) | ||
} | ||
|
||
private fun createRefreshTokenCookie(authTokenInfo: AuthTokenInfo): ResponseCookie { | ||
return ResponseCookie.from("refresh-token", authTokenInfo.refreshToken) | ||
.sameSite("None") | ||
.secure(true) | ||
.httpOnly(true) | ||
.build() | ||
} | ||
} |
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,5 @@ | ||
package com.petqua.presentation.auth | ||
|
||
data class AuthResponse( | ||
val accessToken: String, | ||
) |
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
Oops, something went wrong.