-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#35] 로그인한 유저 인증 기능 추가 #38
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
src/main/java/com/srltas/runtogether/adapter/in/NeighborhoodVerificationController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/srltas/runtogether/adapter/in/web/filter/AuthenticationFilter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/srltas/runtogether/adapter/in/web/filter/AuthenticationFilter.java
Outdated
Show resolved
Hide resolved
- Header에 인증과 키워드들을 상수 클래스로 정의하여 사용
- AuthenticationFilter는 해당 요청이 로그인된 사용자의 요청인지 확인하는 필터입니다 - 해당 필터는 요청 당 한 번만 실행되면 되므로 한 번만 실행될 수 있도록 AuthenticationFileter를 상속했습니다.
src/main/java/com/srltas/runtogether/common/SessionAttribute.java
Outdated
Show resolved
Hide resolved
- filter에서 token이 null인 경우 더 이상 요청을 진행하지 않고 에러를 반환합니다. - controller에서는 filter에서 인증 처리를 했기 때문에, 더 이상 null 체크는 하지 않습니다.
src/test/java/com/srltas/runtogether/adapter/in/NeighborhoodVerificationControllerTest.java
Show resolved
Hide resolved
- Controller와 Filter 두 곳에 URL 관리의 편의성을 위해 constant 클래스를 만들어 한 곳에서 관리합니다
- 로그인 기능을 개발하기 전까지 테스트용으로 사용할 SessionStorage 구현체입니다
로그인 기능을 개발하기 전까지 테스트용으로 사용할 임시 SessionStorage 구현체를 만들어 적용했습니다. |
f-lab-bradley
approved these changes
Oct 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다~
- 저장소에서 유저가 존재하는지 확인하는 메소드(authenticateUser)가 확인 뿐만 아니라 request에 유저 정보를 넣는 역할까지 맞고 있어 책임 분리 - 역할을 명확하게 하기 위해 기존 메소드의 이름을 authenticateUser -> isNullUserSessionDTO로 변경 - doFilterInternal에서 request에 유저 정보를 넣어 Controller에게 전달하는 역할 수행 - 토큰이 null인 경우 저장소에서 유저를 확인하지 않고, 바로 예외 처리를 할 수 있도록 로직 수정
src/main/java/com/srltas/runtogether/adapter/in/web/filter/AuthenticationFilter.java
Show resolved
Hide resolved
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.
📌 Summary
Access Token을 통해 사용자 인증 후, 인증된 사용자 정보를 HttpSession에 저장하여 Controller에서 사용할 수 있도록 하는 로직을 추가했습니다.
📝 Description
AuthenticationFilter
SessionStorage
Controller
✅ Checklist