-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 로깅을 위한 RequestInfo 관련 클래스 추가 * feat: Admin/Auth/Verification API 로깅 추가
- Loading branch information
Showing
8 changed files
with
116 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/uoslife/servermeeting/global/common/dto/RequestInfoDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package uoslife.servermeeting.global.common.dto | ||
|
||
data class RequestInfoDto(val ip: String, val userAgent: String) { | ||
override fun toString(): String { | ||
return "ip: $ip, userAgent: $userAgent" | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/uoslife/servermeeting/global/util/RequestUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package uoslife.servermeeting.global.util | ||
|
||
import jakarta.servlet.http.HttpServletRequest | ||
import org.springframework.stereotype.Component | ||
import uoslife.servermeeting.global.common.dto.RequestInfoDto | ||
|
||
@Component | ||
class RequestUtils { | ||
companion object { | ||
private const val X_FORWARDED_FOR = "X-Forwarded-For" | ||
private const val PROXY_CLIENT_IP = "Proxy-Client-IP" | ||
private const val WL_PROXY_CLIENT_IP = "WL-Proxy-Client-IP" | ||
} | ||
|
||
fun toRequestInfoDto(request: HttpServletRequest) = | ||
RequestInfoDto(ip = getClientIp(request), userAgent = getUserAgent(request)) | ||
|
||
fun getClientIp(request: HttpServletRequest): String = | ||
when { | ||
request.getHeader(X_FORWARDED_FOR) != null -> | ||
request.getHeader(X_FORWARDED_FOR).split(",")[0] | ||
request.getHeader(PROXY_CLIENT_IP) != null -> request.getHeader(PROXY_CLIENT_IP) | ||
request.getHeader(WL_PROXY_CLIENT_IP) != null -> request.getHeader(WL_PROXY_CLIENT_IP) | ||
else -> request.remoteAddr | ||
} | ||
|
||
fun getUserAgent(request: HttpServletRequest): String { | ||
return request.getHeader("User-Agent") ?: "Unknown" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters