0

I'm looking for a good example of login using hexagonal architecture. I use spring boot, but it doesn't matter if you reply in other languages and frameworks.

Send username, password from incoming adapter layer to application layer. The application layer checks for the presence of users through the outgoing adapter.

Now, let's begin the question. JWT [access, refresh] must be issued if the user exists. Is it a good way to issue JWT at the application layer? If it's a good example, how can I implement it? I'm curious about the code that UserService calls JWT. If issuing JWT on the application layer is a bad example, I wonder what is a good example.

Please give me an answer.

@Service
class SignInUserService(
    private val port: SignInUserPort
) : ViewUserQuery {
    override fun signIn(query: ViewUserQuery.Query): ViewUserQuery.Result {

        val findUser = port.load(query.username, query.password) ?: throw CustomException(
            errorCode = ErrorCode.FailedSignIn,
            detailMsg = "Please check your username and password."
        )

        // JWT issue and save logic ??

        return ViewUserQuery.Result(
            userId = findUser.userId!!,
            username = findUser.username!!,
            name = findUser.name!!,
        )
    }
}

Application layer package Structure enter image description here

Now, let's begin the question. JWT [access, refresh] must be issued if the user exists. Is it a good way to issue JWT at the application layer? If it's a good example, how can I implement it? I'm curious about the code that UserService calls JWT. If issuing JWT on the application layer is a bad example, I wonder what is a good example.

0 Answers0