Skip to content

Commit

Permalink
feat: POST /auth/signin,PUT /auth/refresh 엔드포인트 정의
Browse files Browse the repository at this point in the history
code 기반 로그인과 토큰 갱신을 담당하는 엔드포인트를 정의하였습니다

Resolves: #27
  • Loading branch information
snowykte0426 committed Nov 30, 2024
1 parent 8c04c77 commit a4ec357
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ 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")
@RestController
@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
Expand All @@ -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)
}
}

0 comments on commit a4ec357

Please sign in to comment.