Skip to content

Commit

Permalink
♻️ :: secret value 주석 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
jyk1029 committed Aug 21, 2023
1 parent f4bd1c6 commit b1106f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.xquare.v1userservice.user.aop

import com.xquare.v1userservice.jwt.UnAuthorizedException
import com.xquare.v1userservice.user.exceptions.InvalidSecretValueException
import org.springframework.beans.factory.annotation.Value
/*import com.xquare.v1userservice.user.exceptions.InvalidSecretValueException
import org.springframework.beans.factory.annotation.Value*/
import org.springframework.stereotype.Component
import org.springframework.web.reactive.function.server.ServerRequest
import java.util.UUID

@Component
class RequestHeaderAspect(
@Value("\${security.value}")
private val secret: String,
/*@Value("\${security.value}")
private val secret: String,*/
) {

fun getUserId(serverRequest: ServerRequest): UUID {
Expand All @@ -20,10 +20,10 @@ class RequestHeaderAspect(
return UUID.fromString(userId)
}

fun getSecretValue(serverRequest: ServerRequest) {
/*fun getSecretValue(serverRequest: ServerRequest) {
val secretValue = serverRequest.headers().firstHeader("Request-Xquare-Secret")
if ((secretValue == null) || (secretValue != secret)) {
throw InvalidSecretValueException("Secret is invalid")
}
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class UserHandler(

suspend fun getUserByIdHandler(serverRequest: ServerRequest): ServerResponse {
val userId = serverRequest.pathVariable("userId")
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/

val user = userApi.getUserById(UUID.fromString(userId))
val userResponseDto = user.toGetUserByAccountIdResponseDto()
Expand All @@ -102,7 +102,7 @@ class UserHandler(
suspend fun getUserByIdsInHandler(serverRequest: ServerRequest): ServerResponse {
val userIds = serverRequest.queryParams()["userId"]?.map { UUID.fromString(it) }
?: throw BadRequestException("userId is required")
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/

val users = userApi.getUsersByIdsIn(userIds)
val userResponseDtos = users.map { it.toGetUserByAccountIdResponseDto() }
Expand All @@ -112,7 +112,7 @@ class UserHandler(

suspend fun getUserByIdsToBodyHandler(serverRequest: ServerRequest): ServerResponse {
val userIds = serverRequest.getUserInfoRequestBody()
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/

val users = userApi.getUsersByIdsIn(userIds.userIds)
val userResponseDtos = users.map { it.toGetUserByAccountIdResponseDto() }
Expand All @@ -125,7 +125,7 @@ class UserHandler(

suspend fun getUserByAccountIdHandler(serverRequest: ServerRequest): ServerResponse {
val accountId = serverRequest.pathVariable("accountId")
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/

val user = userApi.getUserByAccountId(accountId)
val userResponseDto = user.toGetUserByAccountIdResponseDto()
Expand Down Expand Up @@ -165,7 +165,7 @@ class UserHandler(

suspend fun getUserDeviceTokensHandler(serverRequest: ServerRequest): ServerResponse {
val userIds = serverRequest.getUserIdList().awaitSingle().userIdList
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/

val userDeviceTokenDomainResponse = userApi.getUserDeviceTokensByIdIn(userIds)
val getUserDeviceTokenListResponse = userDeviceTokenDomainResponse.toGetUserDeviceTokenListResponse()
Expand Down Expand Up @@ -204,7 +204,7 @@ class UserHandler(
val grade = serverRequest.queryParams().getFirst("grade")?.toIntOrNull()
?: throw BadRequestException("grade is required")
val classNum = serverRequest.queryParams().getFirst("classNum")?.toIntOrNull()
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/

val users = userApi.getUserByGradeAndClass(grade, classNum)
val userResponse = users.map { it.toGetUserGradeAndClass() }
Expand All @@ -223,7 +223,7 @@ class UserHandler(
}

suspend fun getAllStudentHandler(serverRequest: ServerRequest): ServerResponse {
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/
val users = userApi.getAllStudent()
val userResponseDtos = users.map { it.toGetUserByAccountIdResponseDto() }
val userListResponse = GetUserListResponse(userResponseDtos)
Expand All @@ -232,7 +232,7 @@ class UserHandler(
}

suspend fun getAllTeacherHandler(serverRequest: ServerRequest): ServerResponse {
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/
val teachers = userApi.getAllTeacher()
val teacherInfoResponse = teachers.map { it.toGetTeacherInfoResponseDto() }
val teacherResponse = GetTeacherResponse(teacherInfoResponse)
Expand All @@ -242,7 +242,7 @@ class UserHandler(

suspend fun getAllStudentByNameHandler(serverRequest: ServerRequest): ServerResponse {
val name = serverRequest.queryParam("name").orElse("")
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/

val users = userApi.getAllStudentByName(name)
val userResponse = users.map { it.toGetUserNameResponseDto() }
Expand All @@ -252,7 +252,7 @@ class UserHandler(

suspend fun getUserByRoleHandler(serverRequest: ServerRequest): ServerResponse {
val role = serverRequest.queryParams().getFirst("roleName") ?: throw BadRequestException("roleName is required")
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/
checkUserRole(role)

val users = userApi.getAllUserByRole(role)
Expand Down Expand Up @@ -283,7 +283,7 @@ class UserHandler(
}

suspend fun getExcludeUserListHandler(serverRequest: ServerRequest): ServerResponse {
requestHeaderAspect.getSecretValue(serverRequest)
/*requestHeaderAspect.getSecretValue(serverRequest)*/
val excludeUserIds = serverRequest.getUserIdList().awaitSingle().userIdList.nullIfBlank()?.map { it }
val users = userApi.getExcludeUserIdList(excludeUserIds)
val response = ExcludeUserIdListResponse(users)
Expand Down

0 comments on commit b1106f4

Please sign in to comment.