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

Feature/#17 signup encrypt #18

Open
wants to merge 3 commits into
base: feature/#15-encrypt
Choose a base branch
from

Conversation

kamser0415
Copy link
Collaborator

#️⃣연관된 이슈

#17

📝작업 내용

구매자 회원가입시 암호화/ 복호화 기능을 추가했습니다.

✒️ 코드 변경 이유

  • SymmetricCryptoService 인터페이스를 만들었습니다.
  • 암호화 클래스를 빈으로 등록하고 SymmetricCryptoService을 구현했습니다.
  • 암호화 구현 방식이 달라질 수 있으므로 결합도를 낮추려고 했습니다.

💬리뷰 요구사항(선택)

객체지향 체조 3가지 확인📌

  • 한 줄에 점을 하나만 찍는다.
  • else 키워드를 쓰지 않는다.
  • 일급 컬렉션을 사용한다.

@kamser0415 kamser0415 changed the base branch from feature/#11-sign-up to features October 30, 2024 09:24
@kamser0415 kamser0415 changed the base branch from features to feature/#15-encrypt October 30, 2024 09:24
*/
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@ToString
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 어노테이션에 대한 설명이 없습니다. ToString 을 추가하신 이유가 무엇인가요~?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 제거하고 올렸어야했는데 제거하겠습니다.

public static BuyerResponse of(Buyer buyer) {
return new BuyerResponse(buyer.getBuyerId(), buyer.getEmail(), buyer.getName(), buyer.getPhoneNumber(),
buyer.getBuyerStatus());
public static BuyerResponse of(Buyer buyer, final String email, final String phoneNumber) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email 과 phonNumber 도 결국 buyer 의 정보아닌가요? 따로 받는 이유가 있으신가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

응답으로 반환할 때는 복호화를 해서 반환하고 싶었습니다.

@@ -27,10 +33,14 @@ public class BuyerService implements LoginHandler {
*/
@Transactional
public BuyerResponse signUp(final BuyerRequest buyerRequest, final LocalDateTime createdAt) {
final Buyer buyer = Buyer.create(buyerRequest.email(), buyerRequest.password(), buyerRequest.name(),
final String encryptEmail = symmetricCryptoService.encrypt(buyerRequest.email());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encryptEmail 은 명사로 변수이름으로는 부적합합니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 수정하겠습니다 !!

.orElseThrow(() -> new IllegalArgumentException("해당 이메일로 가입된 회원이 없습니다."));
findBuyer.validatePassword(user.password());
return LoginResponse.of(findBuyer);
final String encryptPassword = encryptPassword(user.password(), findBuyer.getSalt());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email 과 일관성있게 encrypted 가 더 적합해보입니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 변경하도록 하겠습니다

@@ -0,0 +1,8 @@
package shop.sendbox.sendbox.buyer;

public interface SymmetricCryptoService {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HashingEncrypt 와 다르게 interface 로 분리한 이유는 무엇인가요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음에 암호화 라이브러리를 직접 의존하지 않으려고 했습니다.
만들고 올리고 나니 라이브러리 내부 동작이 어떻게 되는지에 따라 결과가 달라지기 때문에
결합도를 낮춘다고 하더라도 자유로운 변경이 어렵다는 걸 알게 되었습니다.

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.

2 participants