Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/api/users/token-check 가 동시에 2번 호출될 경우 2번째 요청은 403 에러를 반환 #27

Closed
ucharles opened this issue Apr 3, 2022 · 3 comments
Assignees
Labels
backend bug Something isn't working frontend question Further information is requested

Comments

@ucharles
Copy link
Owner

ucharles commented Apr 3, 2022

현상

  1. 루트 경로(/)에서 getPermission이 2번 호출되고 있음.
  2. getPermission에서 /api/users/token-check을 동시에 2번 호출.
  3. 1번째 응답은 정상, 2번째 응답은 에러.

원인(추측)

  1. Refresh Token이 7일 이하로 남으면 DB update가 일어남.
  2. 백엔드 코드가 잘못되어 매 요청마다 DB update가 일어나고 있었음. (에러의 직접적인 원인은 아님)
  3. 동일한 Refresh Token으로 getPermission에서 /api/users/token-check을 동시에 2번 호출.
  4. 1번째 요청은 정상적으로 처리되어 DB가 update 됨.
  5. 2번째 요청은 update된 DB 정보를 반영하지 못한 채 일어나므로, 에러로 응답.

해결책

  • getPermissionasync/await 추가?
    • 실험결과, 효과 없음
  • getPermission이 동시에 1번만 일어나도록 하게 함.
    • 루트 경로(/)를 <CustomRoutes>로 이동

관련 이슈

#8 Refresh Token 적용하기

@ucharles ucharles added bug Something isn't working question Further information is requested frontend backend labels Apr 3, 2022
@ucharles
Copy link
Owner Author

ucharles commented Apr 3, 2022

백엔드 수정 완료 0e32efb

@yypp1226
Copy link
Collaborator

수정 확인 했습니다~ 감사합니다

@ucharles
Copy link
Owner Author

ucharles commented Apr 14, 2022

30d0e94
백엔드의 token-check API에서 DB �update(refresh token 갱신)을 하지 않도록 변경.
또한, loggedIn 쿠키를 추가하여 API 접근을 줄이고자 함.
(loggedIn 쿠키: 브라우저 읽기 가능. refresh token과 같은 갱신주기, 유효기간 14일, 갱신 타이밍은 남은 유효기간이 7일 이하, 없을 경우 강제 로그아웃)

이 변경사항으로 refresh token 갱신 타이밍에 token-check API가 동시에 2번 호출되어도 403 에러를 반환하지 않음.
Close 하겠습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working frontend question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants