-
Notifications
You must be signed in to change notification settings - Fork 4
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
[Feat] https로 토큰 쿠키 보내기 #173
Merged
Merged
Conversation
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
hyehyeonmoon
force-pushed
the
feat/https_cookie
branch
from
November 27, 2021 02:05
df738c8
to
0384faf
Compare
localhost에서 개발환경을 구성하기 위해 인증서를 받아야 함 react 개발 script를 바꿈
개발환경에서 port가 다르기 때문에 CORS 에러가 나므로 credentials 옵션을 추가
기존의 데이터를 보내는 형식에서 cookie를 secure, http only option을 제공
각 상황에 맞게 만료시간을 세션에 저장 cookie 변경됨에 따라 token, refreshToken 제거하고 맞추어 type 변경
https 설정에 맞게 fetch option 수정과 header 생성로직 제거 토큰 만료 시간 세션에 저장
에러 발생 시 access token과 refresh token을 지우고 다시 로그인하게 만듦 try, catch문이 빠진 곳에 넣음
시간이 드러나지 않도록 환경변수로 만듦 개발과 배포 환경 때 시간을 다르게 설정하기 때문에 환경변수로 만듦
unload event를 window에 걸어서 cookie를 제거하도록 함
* Refactor: #177 - fetch 중복 옵션을 getOptions 함수로 묶음 fetch option 중복되는 것을 getOptions에서 하나로다룰 수 있도록 만듦 보안을 위해 'include' 대신 'same-origin'을 사용했고 cookie가 필요하지 않은 api는 'omit'으로 만듦 * Refactor: #177 - same-origin을 include로 바꾸고 cookie 생성과 제거 중복함수 제거 same-origin과 lax을 했을 때, 요청헤더에만 오고 저장이 안되는 문제가 발생해서 include와 none으로 변경 쿠키 생성과 제거함수 중복을 제거하기 위해 일반화 함수를 만듦 * [Feat] 직접 url을 쳤을 때 들어가지 못하게 막는 protectRoute (#184) * Feat: #182 - /github/callback 잘못된 접근 막기 code가 없는 경우 thorw error를 잡을 수 있도록 try..catch 문 안으로 넣기 * Feat: #182 - publicRoute 구현 location.state로 구분하였고 새로고침하면 location.state 값이 남아있어서 그대로 유지됨 url에 그대로 치면 location.state가 없기 때문에 안되고 console 창에 history.push를 해도 컴포넌트가 렌더링되지 않아서 위험이 적음 로그인 되어있지 않은 상황에서는 url을 직접 치면 모두 튕겨냄 로그인 되어 있는 상태에서 loading 페이지는 privateRoute에 의해 사용되기 때문에 loadingPage에는 직접 못들어가지만 로그인은 유지되는 현상을 볼 수 있음
hyehyeonmoon
force-pushed
the
feat/https_cookie
branch
from
November 28, 2021 16:29
92cd596
to
6c2db6d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔨 작업 내용 설명
📑 구현한 내용
🚧 주의 사항
현재 일부러 access token 만료기간=5m, refresh token 만료기간 = 30m,access 쿠키 만료 시간 = 15m, Refresh 쿠키 만료 시간 = 30m으로 모두 짧게 주었습니다. 예기치 못한 오류를 발견하기에 좋을 것 같아 일부러 짧게 만들었습니다.
Front의 recoil 설정값인 oauth_email을 oauthEmail로 바꾸었습니다. 그 이유는 oauth_email과 oauthEmail이 혼용되어 사용되어서 통일되어야 사용하기 편할 것 같아서입니다. 백엔드도 db key값을 제외하고 모두 바꾸었으면 하는 바랍입니다.
다음 개발을 하기 위해 환경변수 설정을 바꾸셔야 하고 https 개발환경을 만들기 위해 아래 사항들을 따라해 주세요. 참고
[### 스크린 샷]
[issue | close] #[ISSUE_NUMBER]