From a4ec357002db6a091a6f0857933b40cc09eade22 Mon Sep 17 00:00:00 2001 From: snowykte0426 Date: Sat, 30 Nov 2024 19:55:31 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20``POST=20/auth/signin``,``PUT=20/auth/r?= =?UTF-8?q?efresh``=20=EC=97=94=EB=93=9C=ED=8F=AC=EC=9D=B8=ED=8A=B8=20?= =?UTF-8?q?=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit code 기반 로그인과 토큰 갱신을 담당하는 엔드포인트를 정의하였습니다 Resolves: #27 --- .../domain/auth/controller/AuthController.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/rainbowfriends/daramserverv2/domain/auth/controller/AuthController.kt b/src/main/kotlin/rainbowfriends/daramserverv2/domain/auth/controller/AuthController.kt index 33ba595..08851a1 100644 --- a/src/main/kotlin/rainbowfriends/daramserverv2/domain/auth/controller/AuthController.kt +++ b/src/main/kotlin/rainbowfriends/daramserverv2/domain/auth/controller/AuthController.kt @@ -6,9 +6,13 @@ import jakarta.servlet.http.HttpServletRequest import org.springframework.http.HttpStatus import org.springframework.web.bind.annotation.* import rainbowfriends.daramserverv2.domain.auth.dto.AuthorizeAdminRequest +import rainbowfriends.daramserverv2.domain.auth.dto.request.ReissueRequest import rainbowfriends.daramserverv2.domain.auth.dto.request.SignInRequest +import rainbowfriends.daramserverv2.domain.auth.dto.response.SigninOrReissueResponse import rainbowfriends.daramserverv2.domain.auth.service.AdminAuthorizationService import rainbowfriends.daramserverv2.domain.auth.service.LogoutService +import rainbowfriends.daramserverv2.domain.auth.service.ReissueService +import rainbowfriends.daramserverv2.domain.auth.service.SignInService import rainbowfriends.daramserverv2.global.security.dto.TokenResponse @RequestMapping("/auth") @@ -16,7 +20,9 @@ import rainbowfriends.daramserverv2.global.security.dto.TokenResponse @Tag(name = "Auth", description = "관리자 인증 API") class AuthController( private val adminAuthorizationService: AdminAuthorizationService, - private val logoutService: LogoutService + private val logoutService: LogoutService, + private val signInService: SignInService, + private val reissueService: ReissueService ) { @Operation(summary = "관리자 인증", description = "관리자 권한을 인가합니다") @PostMapping @@ -35,7 +41,13 @@ class AuthController( @Operation(summary = "로그인", description = "로그인합니다") @PostMapping("/signin") - fun signIn(@RequestBody code: SignInRequest): TokenResponse { + fun signIn(@RequestBody code: SignInRequest): SigninOrReissueResponse { + return signInService.signIn(code.code) + } + @Operation(summary = "토근 갱신", description = "토큰을 갱신합니다") + @PutMapping("/refresh") + fun reissue(@RequestBody refreshToken: ReissueRequest): SigninOrReissueResponse { + return reissueService.reissue(refreshToken.refreshToken) } } \ No newline at end of file