-
Notifications
You must be signed in to change notification settings - Fork 0
[#2] JWT 로그인 #26
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
base: main
Are you sure you want to change the base?
[#2] JWT 로그인 #26
Conversation
f-lab-saponin
left a comment
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.
고생하셨습니다👍 리뷰한번 확인부탁드려요!
README.md
Outdated
| ### 🔹 방법 1) Docker MySQL + IDE(인텔리제이) 앱 실행 | ||
|
|
||
| MySQL만 Docker로 실행하고, Spring Boot 앱은 IDE에서 실행하는 방식입니다. | ||
|
|
||
| ```bash | ||
| docker compose up -d mysql | ||
| ``` | ||
|
|
||
| ### 🔹 방법 2) Docker MySQL + Docker Spring Boot 앱 실행 (전체 Docker 실행) | ||
|
|
||
| MySQL과 Spring Boot 앱을 모두 Docker로 실행하는 방식입니다. | ||
| ```bash | ||
| docker compose up -d mysql | ||
| docker compose up -d --build |
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.
하나로 정해서 정리하면 좋아보여요🙂
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.
하나로 정리 완료했습니다!
| // CREATOR는 MEMBER 권한 + CREATOR 권한을 모두 가진다 | ||
| CREATOR(Set.of("ROLE_MEMBER", "ROLE_CREATOR")); |
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.
👍
| @PostMapping("/make") | ||
| public ResponseEntity<Map<String, String>> makeToken(@RequestBody LoginRequest loginRequest) { |
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.
하는 일이 로그인 같은데 "/login" 해도 될것같아요 🙂
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.
변경 완료했습니다!
| @Column(nullable = false, unique = true) | ||
| private String email; | ||
|
|
||
| @Column(nullable = false) | ||
| private String password; | ||
|
|
||
| @Column(nullable = false, length = 150) | ||
| private String name; |
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.
unique 는 고민해보시고
LoginRequest 에 있는 검증처럼 length 도 DB 타입에 넣어놓으면 좋을것같아요
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.
email, password 각각 DTO에 맞춰 length추가 완료했습니다!
| import java.util.Optional; | ||
|
|
||
| public interface MemberRepository extends JpaRepository<Member, Long> { | ||
| Optional<Member> findByEmail(String email); |
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.
INDEX 생성하셨다면 DDL 관리를위해 이것도 ddl 파일에 기록해주세요!
| @Component | ||
| @Slf4j | ||
| public class JWTUtil { | ||
| private final SecretKey secretKey; |
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.
accessToken 과 refreshToken 의 secretKey 는 다르게 하는게 보안을 더 향상할 수 있는 방법이예요.
어떻게 만들면 좋을지 고민해보면 좋겠습니다. 🙂
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.
secretKey 분리 완료했습니다
| @Transactional | ||
| public MemberResponse signup(MemberRequest memberRequest) { |
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.
@Transactional 이 꼭 필요하면 넣으면 좋아보여요. 필요할까요?
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.
회원가입 쪽은 나중에 초기 캐시 적립이나 다른 작업들이 묶일 수도 있을 것 같아서 일단은 @Transactional 유지해뒀어요.
이렇게 해도 괜찮을까요?
| @Transactional | ||
| public void deleteMember(Long memberId) { |
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.
여기두요 🙂
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.
회원가입과 마찬가지로 삭제시 같이 지워야 할 연관 데이터와 같은 다른 작업이 묶일수도 있다고 생각해서 일단 @Transactional 유지해 두었습니다.
src/main/resources/application.yml
Outdated
| jwt: | ||
| secret: ${JWT_SECRET:1234567890123456789012345678901234567890} |
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.
secretKey 노출이 안되도록 해볼까요?
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.
.env 파일로 secretKey 및 DB 접속정보 처리했습니다
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.
application.yaml + gitignore 조합도 추천합니다 🙂
| import static org.assertj.core.api.Assertions.*; | ||
|
|
||
| @SpringBootTest | ||
| //@Transactional |
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.
이건 의도하신걸까요? 데이터를 생성하고 다시 삭제하는걸 의도하셨다면 유지해야할 것 같아요.
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.
잠깐 DB 데이터 확인 후 주석을 푼다는 걸 깜빡했네요! 원래대로 돌려놨습니다
|
f-lab-saponin
left a comment
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.
리뷰 반영해주시느라 고생하셨습니다 승인드립니다. 🙂
추가 코멘트 드린 부분 + Transactional 부분은 선택이니 고민해보시고 반영부탁드려요



작업 내용
테스트 내용
추가 필요