Skip to content

Commit

Permalink
feat: 유저 ID 파서 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Oct 30, 2023
1 parent a6a1448 commit e3c9ae0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ package kr.nagaza.nagazaserver.domain.exception

class AuthTokenNotValidException : DomainException(ErrorCode.TOKEN_NOT_VALID)
class OAuthLoginFailedException : DomainException(ErrorCode.OAUTH_LOGIN_FAILED)
class NotAuthenticatedException: DomainException(ErrorCode.NOT_AUTHENTICATED)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package kr.nagaza.nagazaserver.presenter.restapi.advice

import kr.nagaza.nagazaserver.domain.exception.NotAuthenticatedException
import kr.nagaza.nagazaserver.presenter.restapi.advice.filter.APIKeyAuthentication
import org.springframework.core.MethodParameter
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.stereotype.Component
Expand All @@ -21,7 +23,7 @@ class RequestUserArgumentResolver : HandlerMethodArgumentResolver {
binderFactory: WebDataBinderFactory?,
): Any {
val authorization = SecurityContextHolder.getContext().authentication
// if (authorization !is APIKeyAuthentication) throw UnAuthenticatedException()
return authorization.name
if (authorization !is APIKeyAuthentication) throw NotAuthenticatedException()
return authorization.userId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package kr.nagaza.nagazaserver.presenter.restapi.advice.filter
import org.springframework.security.core.Authentication

class APIKeyAuthentication(
private val userId: String,
val userId: String,
private val token: String,
) : Authentication {
private var authenticated = true
Expand Down

0 comments on commit e3c9ae0

Please sign in to comment.