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

[Feat] 유저 관련 로직 추가 #16

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Conversation

leesy010504
Copy link
Collaborator

@leesy010504 leesy010504 commented Jan 30, 2025

💡 ISSUE

✅ KEY-CHANGES

1️⃣ 회원가입, 로그인 로직 추가

-> 소셜 로그인으로 바꾸는 작업 중입니다.

2️⃣ 로그인 과정

  1. 유저가 /api/user/login/local으로 email을 비밀번호(소셜로그인 구현 후 변경예정)와 함께 POST요청 하면, LoginFilter에서 요청을 받아 진행합니다.
  2. LoginFilter에서 간단한 검증 이후, 요청으로 들어온 이메일과 비밀번호를 사용해 UsernamePasswordAuthenticationToken을 생성하여 authenticationManager의 authenticate메소드를 실행해 Spring Security에서DB의 값과 email과 password를 비교검증 합니다. 검증이 성공한다면 아래의 successfulAuthentication가, 실패한다면 unsuccessfulAuthentication 메소드가 실행됩니다.
  3. successfulAuthentication에서는 authentication객체 안에 있는 유저의 아이디와 role을 꺼내 Access Token과 Refresh Token을 생성합니다. 현재는 Access Token은 10분, Refresh Token은 1일의 유효기간을 가지고 있습니다. 생성된 Access Token은 response의 body값으로, Refresh Token은 쿠키값으로 리턴됩니다.

3️⃣ Refresh Token Rotate 구현

매 Reissue마다 새 Refresh Token을 발급해 반환하여 인증의 주도권을 서버가 가지게 하고, 새 Refresh Token은 DB에 저장됩니다.
@scheduled를 사용해 24시간마다 만료된 토큰을 DB에서 제거하도록 했습니다.
추후 Redis를 사용한다면 TTL설정으로 자동으로 지워지게 할 예정입니다.

4️⃣ Logout Filter 추가

Logout Filter를 추가하여 현재 사용 중인 Refresh Token을 제거하고 빈 쿠키를 리턴하게 하였습니다.

💬 TO REVIEWER

이거 마무리 하고 restdocs도 공부해서 만간에 업데이트 해 놓겠습니다,,
예외 처리를 너무 이상하게 해 놓았는데 기능 구현 어느 정도 진행하고 싹 다 뜯어 고치겠습니다..

@leesy010504 leesy010504 self-assigned this Jan 30, 2025
@leesy010504 leesy010504 added the enhancement New feature or request label Jan 30, 2025
@leesy010504 leesy010504 changed the base branch from main to develop January 30, 2025 10:53
@leesy010504 leesy010504 changed the title Feat/#15 sign up Feat/#15 유저 관련 로직 추가 Jan 30, 2025
@leesy010504 leesy010504 changed the title Feat/#15 유저 관련 로직 추가 [Feat] 유저 관련 로직 추가 Jan 30, 2025
@leesy010504 leesy010504 removed the enhancement New feature or request label Feb 4, 2025
@leesy010504 leesy010504 changed the title [Feat] 유저 관련 로직 추가 [Feat] 자체 로그인 관련 로직 추가 Feb 4, 2025
@leesy010504 leesy010504 changed the title [Feat] 자체 로그인 관련 로직 추가 [Feat] 유저 관련 로직 추가 Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] : 유저 관련 로직 추가
1 participant