Skip to content

Commit

Permalink
chore: package 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
suw0n committed May 28, 2024
1 parent d5e2a7c commit 2a47578
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 61 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package b1nd.tokenserver.auth.domain.model
package b1nd.tokenserver.domain.auth.core

data class Token(
val subject: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package b1nd.tokenserver.domain.auth.core.exception

import b1nd.tokenserver.domain.common.core.BaseException

object EmptyTokenException : BaseException(
400, "토큰이 전송되지 않았습니다"
)

object InvalidTokenException : BaseException(
401, "위조된 토큰입니다"
)

object WrongTokenTypeException : BaseException(
401, "잘못된 토큰 타입입니다"
)

object ExpiredTokenException : BaseException(
410, "만료된 토큰입니다"
)
12 changes: 12 additions & 0 deletions src/main/kotlin/b1nd/tokenserver/domain/auth/outport/TokenPort.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package b1nd.tokenserver.domain.auth.outport

import b1nd.tokenserver.domain.auth.core.JWTType
import b1nd.tokenserver.domain.auth.core.Token

interface TokenPort {

fun issue(subject: String, role: Int, type: JWTType): String

fun parse(token: String, type: JWTType): Token

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package b1nd.tokenserver.auth.application.usecase
package b1nd.tokenserver.domain.auth.usecase

import b1nd.tokenserver.auth.application.outport.TokenPort
import b1nd.tokenserver.auth.application.usecase.data.*
import b1nd.tokenserver.auth.domain.model.JWTType
import b1nd.tokenserver.auth.domain.model.Token
import b1nd.tokenserver.auth.domain.model.exception.WrongTokenTypeException
import b1nd.tokenserver.domain.auth.outport.TokenPort
import b1nd.tokenserver.domain.auth.core.JWTType
import b1nd.tokenserver.domain.auth.core.Token
import b1nd.tokenserver.domain.auth.core.exception.WrongTokenTypeException
import b1nd.tokenserver.domain.auth.usecase.data.*
import org.springframework.stereotype.Component

@Component
Expand All @@ -14,6 +14,7 @@ class AuthUseCase(val tokenPort: TokenPort) {
return issueToken(req, JWTType.ACCESS)
}

//todo Redis 조회
fun reissueAccessToken(req: ReissueAccessTokenRequest): TokenResponse {
val token: Token = tokenPort.parse(req.refreshToken, JWTType.REFRESH)
if(token.isNotRefreshToken()) {
Expand All @@ -22,6 +23,7 @@ class AuthUseCase(val tokenPort: TokenPort) {
return issueToken(IssueTokenRequest(token.subject, token.role), JWTType.ACCESS)
}

//todo Redis 저장
fun issueRefreshToken(req: IssueTokenRequest): TokenResponse {
return issueToken(req, JWTType.REFRESH)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package b1nd.tokenserver.auth.application.usecase.data
package b1nd.tokenserver.domain.auth.usecase.data

data class VerifyTokenRequest(val token: String)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package b1nd.tokenserver.auth.application.usecase.data
package b1nd.tokenserver.domain.auth.usecase.data

data class TokenResponse(
val token: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package b1nd.tokenserver.global.exception.model
package b1nd.tokenserver.domain.common.core

open class BaseException(val status: Int, override val message: String) : RuntimeException()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package b1nd.tokenserver.auth.infrastructure.adapter.driven.jwt
package b1nd.tokenserver.infrastructure.adapter.driven.jwt

import b1nd.tokenserver.auth.application.outport.TokenPort
import b1nd.tokenserver.auth.domain.model.*
import b1nd.tokenserver.auth.domain.model.exception.EmptyTokenException
import b1nd.tokenserver.auth.domain.model.exception.ExpiredTokenException
import b1nd.tokenserver.auth.domain.model.exception.InvalidTokenException
import b1nd.tokenserver.global.exception.model.InternalServerException
import b1nd.tokenserver.domain.auth.outport.TokenPort
import b1nd.tokenserver.domain.auth.core.exception.EmptyTokenException
import b1nd.tokenserver.domain.auth.core.exception.ExpiredTokenException
import b1nd.tokenserver.domain.auth.core.exception.InvalidTokenException
import b1nd.tokenserver.domain.auth.core.JWTType
import b1nd.tokenserver.domain.auth.core.Token
import b1nd.tokenserver.domain.common.core.InternalServerException
import io.jsonwebtoken.*
import io.jsonwebtoken.security.Keys
import org.springframework.stereotype.Component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package b1nd.tokenserver.auth.infrastructure.adapter.driven.jwt
package b1nd.tokenserver.infrastructure.adapter.driven.jwt

import org.springframework.boot.context.properties.ConfigurationProperties

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package b1nd.tokenserver.auth.infrastructure.adapter.driving.web
package b1nd.tokenserver.infrastructure.adapter.driving.web.auth

import b1nd.tokenserver.auth.application.usecase.AuthUseCase
import b1nd.tokenserver.auth.application.usecase.data.*
import b1nd.tokenserver.global.data.response.BaseResponse
import b1nd.tokenserver.domain.auth.usecase.AuthUseCase
import b1nd.tokenserver.domain.auth.usecase.data.*
import b1nd.tokenserver.infrastructure.global.data.response.BaseResponse
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package b1nd.tokenserver.global.exception.model
package b1nd.tokenserver.infrastructure.global.data.response

data class BaseErrorResponse(val status: Int, val message: String)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package b1nd.tokenserver.global.data.response
package b1nd.tokenserver.infrastructure.global.data.response

data class BaseResponse<T>(val status: Int, val message: String, val data: T)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package b1nd.tokenserver.global.exception.handler
package b1nd.tokenserver.infrastructure.global.exception.handler

import b1nd.tokenserver.global.exception.model.BaseErrorResponse
import b1nd.tokenserver.global.exception.model.BaseException
import b1nd.tokenserver.global.exception.model.InternalServerException
import b1nd.tokenserver.infrastructure.global.data.response.BaseErrorResponse
import b1nd.tokenserver.domain.common.core.BaseException
import b1nd.tokenserver.domain.common.core.InternalServerException
import org.slf4j.LoggerFactory
import org.springframework.boot.autoconfigure.web.WebProperties
import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler
Expand All @@ -22,7 +22,7 @@ class ExceptionExchangeHandler(
webProperties: WebProperties,
applicationContext: ApplicationContext,
serverCodecConfigurer: ServerCodecConfigurer
): AbstractErrorWebExceptionHandler(
) : AbstractErrorWebExceptionHandler(
errorAttributes,
webProperties.resources,
applicationContext
Expand Down Expand Up @@ -51,4 +51,4 @@ class ExceptionExchangeHandler(
return ServerResponse.status(e.status).bodyValue(BaseErrorResponse(e.status, e.message))
}

}
}

0 comments on commit 2a47578

Please sign in to comment.