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

Authentication 구조 개선 #87

Closed
3 tasks done
gimhanul opened this issue Jul 17, 2022 · 5 comments · Fixed by #101
Closed
3 tasks done

Authentication 구조 개선 #87

gimhanul opened this issue Jul 17, 2022 · 5 comments · Fixed by #101
Assignees
Labels
✨ Feature 새로운 기능 개발

Comments

@gimhanul
Copy link
Member

gimhanul commented Jul 17, 2022

✨ Describe

현재 cookie에 담아서 날려주는 그런 구조인데, client 측에서 access token을 header에 담아서 날리도록 구조를 변경해야합니다.
또한 refresh token도 어떻게 해야 됨

✅ Tasks

  • access token 발급 logic
  • refresh token 관련 logic
  • cookie 이런 친구들 삭제

🙋🏻 Halmal

No response

@gimhanul gimhanul added the ✨ Feature 새로운 기능 개발 label Jul 17, 2022
@gimhanul gimhanul self-assigned this Jul 17, 2022
@leekyukin
Copy link
Member

이거 설명 좀 해주세요

@leekyukin
Copy link
Member

우리 프로젝트가 앱이라서 그런건가요

@gimhanul
Copy link
Member Author

지금 authentication 과정이

  • 발급(로그인): 쿠키에 access token, refresh token 담아서 보냄
  • 사용
    1. 프론트 측에서 요청시 요청 마다 쿠키에 access token, refresh token 둘 다 담아서 보냄
    2. access token 만료시 -> 그냥 쿠키에서 refresh token 깜

이런 구조인데 이게 솔직히 원래 동작 과정이랑 안 맞습니다

사용할 때 알고리즘이

  1. 프론트 측에서 요청시 요청 마다 access token만 보냄
  2. access token 만료시 백엔드에서 프론트에다 만료 됐다고 response 보냄
  3. 그럼 프론트에서 최후의 보루로 refresh token 보내고
  4. 그럼 백엔드에서 access token 새로 발급해서 보내줌 (refresh token도 만료됐으면 그냥 다시 로그인시키고)
  5. 그럼 그 access token 으로 다시 지지고볶고 하는

뭐 이렇게 동작해야 하는데 좀 많이 쉽지 않게 만들어 놨습니다 ㅎㅎ...

그래서 이렇게 Request response 반복해야하니까 request header에 넣어서 만들자는 것이지용

@leekyukin
Copy link
Member

와우 설명 감사합니다.
근데 원레 refresh token의 용도가 뭔가요

@gimhanul
Copy link
Member Author

access token은 보안상 유효 시간을 짧게 해놓고 refresh token은 길게 해놓급니다 (자동로그인st) 그래서 refresh token으로 새로운 access token을 발급시켜주는 거예요

이 글 읽어보면 좋을듯하네용

gimhanul added a commit that referenced this issue Jul 24, 2022
- cookie 들어가는 부분 다 삭제
gimhanul added a commit that referenced this issue Jul 24, 2022
- user에서 auth 분리
- login, logout logic 분리
- logout 할 때 쿠키 지워주는 건 프론트측으로 책임전가
- url 매핑 변경
gimhanul added a commit that referenced this issue Jul 24, 2022
- user에서 auth 분리
- login, logout logic 분리
- logout 할 때 쿠키 지워주는 건 프론트측으로 책임전가
- url 매핑 변경
gimhanul added a commit that referenced this issue Jul 24, 2022
- json header 사용하도록 수정
- access token만 확인하도록 수정
gimhanul added a commit that referenced this issue Jul 24, 2022
- refresh token 만료됐을때 날리는 exception 정의
gimhanul added a commit that referenced this issue Jul 24, 2022
- header에 넣어서 보내는 것으로...!
- 만료됐으면 만료 떤지기
gimhanul added a commit that referenced this issue Jul 24, 2022
- 유효기간이 엄청 길었던 문제 해결
- 단위가 milli second인데 그냥 second로 들어가고 있었음~
@gimhanul gimhanul mentioned this issue Jul 24, 2022
@gimhanul gimhanul pinned this issue Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 새로운 기능 개발
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants