Skip to content

Commit 0e00baa

Browse files
committed
Feat: 재발급 중복 호출 방지를 위한 헤더 추가
- TokenAuthenticator에서 AUTO_LOGIN_HEADER가 있는 경우 인증을 건너뛰도록 수정
1 parent 6911cc9 commit 0e00baa

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

core/network/src/main/java/com/threegap/bitnagil/network/auth/TokenAuthenticator.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class TokenAuthenticator(
1919
private val authMutex = Mutex()
2020

2121
override fun authenticate(route: Route?, response: Response): Request? {
22+
if (response.request.header(AUTO_LOGIN_HEADER) != null) return null
2223
if (!shouldRetry(response)) return null
2324

2425
val currentToken = runBlocking { tokenProvider.getAccessToken() }
@@ -82,6 +83,7 @@ class TokenAuthenticator(
8283
private fun buildRequestWithToken(originalRequest: Request, token: String): Request {
8384
return originalRequest.newBuilder()
8485
.header(AUTHORIZATION, "$TOKEN_PREFIX $token")
86+
.removeHeader(AUTO_LOGIN_HEADER)
8587
.build()
8688
}
8789

@@ -96,5 +98,6 @@ class TokenAuthenticator(
9698
private const val AUTHORIZATION = "Authorization"
9799
private const val TOKEN_PREFIX = "Bearer"
98100
private const val SUCCESS_CODE = "CO000"
101+
private const val AUTO_LOGIN_HEADER = "Auto-Login"
99102
}
100103
}

data/src/main/java/com/threegap/bitnagil/data/auth/service/AuthService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface AuthService {
2929
suspend fun postLogout(): BaseResponse<Unit>
3030

3131
@POST("/api/v1/auth/token/reissue")
32-
@Headers("No-Service-Token: true")
32+
@Headers("No-Service-Token: true", "Auto-Login: true")
3333
suspend fun postReissueToken(
3434
@Header("Refresh-Token") refreshToken: String,
3535
): BaseResponse<LoginResponseDto>

0 commit comments

Comments
 (0)