Skip to content

Conversation

@snowykte0426
Copy link
Member

@snowykte0426 snowykte0426 commented Mar 28, 2025

💡 PR 요약

  • 인증/인가 로직 부분의 Application,Persistence 계층을 대대적으로 수정했습니다
  • API 명세서와 일치하지 않던 부분을 수정하였습니다
    Resolves: [Refactor] 프로젝트 리팩터링 #14

📋 작업 내용

다른 모델들과 패키지 구조가 판이하게 다르던 부분들을 수정하였습니다.API 명세서의 요구사항을 철저히 따르지 않던 부분 역시 수정하여 명세서와 일치하도록 하였습니다

🤝 리뷰 시 참고사항

✅ 체크리스트

  • 이 작업으로 인해 변경이 필요한 문서를 작성 또는 수정했나요? (e.g. README, .env.example)
  • 작업한 코드가 정상적으로 동작하는지 확인했나요?
  • 작업한 코드에 대한 테스트 코드를 작성하거나 수정했나요?
  • Merge 대상 브랜치를 올바르게 설정했나요?
  • 해당 PR과 관련 없는 작업이 포함되지는 않았나요?
  • PR의 올바른 라벨과 리뷰어를 설정했나요?

추가적으로 요구될 수 있는 프로퍼티들을 정의하였습니다
요구되는 환경변수 목록을 갱신하였습니다
불필요하여진 DTO 클래스를 완전히 삭제하였습니다
리팩터링 전 사전협의에 따라 제거가 계획던 것들을 전부 제거하였습니다
어노테이션이 다른 어노테이션을 생성할 때만 사용되는게 아니라 일반적인 클래스와 인터페이스에도 적용될 수 있도록 조정하였습니다
애플리케이션을 실행시키기 위하여 필요한 환경변수 리스트를 갱신하였습니다
기존에는 코드 내부에 하드코딩 되어 있던 Email 단기간 인증 최대치를 환경변수를 이용하여 유동적으로 주입할 수 있도록 수정하였습니다
비동기 메서드를 구현 및 사용하기 위하여 비동기 처리를 활성화 하였습니다
인증/인가를 수행하는 컨트롤러 클래스를 선언 및 구현하였습니다
인증/인가 처리 모델의 Application 계층의 Port와 Adapter를 구현하였습니다
기존 프로젝트 구조와 판이한 위치에 위치해 있던 클래스와 인터페이스 위치를 조정하였습니다
기존 Web 계층의 요청/응답 DTO들을 Recode로 마이그레이션 하는 작업을 수행하였습니다
JWT 처리를 위해 토큰 정보를 이동시키는 DTO 레코드를 정의하였습니다
로그인,회원가입,이메일 인증 등을 처리하는 Use Case 클래스들을 구현하였습니다
JWT를 발행,파싱,관리하는 서비스 인터페이스/클래스를 구현하였습니다
이메일 정보를 이용하여 관련한 사용자가 존재하는지 확인하는 메서드를 구현하였습니다
사전에 주석에 작성된 대로 몇가지 불필요 메서드를 제거하고 분리 가능한 부분을 분리하였습니다
JWT 인증/인가를 처리하는 필터를 재조직하여 변경된 JWT 관련 로직에 대응되도록 하였습니다
기존 타 클래스에 메서드로서 존재하던 클래스를 분리하였습니다
리프레시 토큰을 Redis에 저장/관리하는 클래스와 인터페이스를 선언하였습니다
8자리 랜덤 코드를 생성하는 클래스를 생성하여 코드 중복을 방지하였습니다
주석처리되어 있던 DI를 제거하였습니다
Spring 템플릿 엔진 사용을 위해 종속성을 추가하였습니다
이메일을 전송하는 클래스를 구현하였습니다
예외가 발생할 수 있음을 메서드 시그니처에 명시하였습니다
기존 단순 문자열로 전송하던 인증 코드를 HTML 렌더링을 추가하였습니다
이메일 HTML에 포함된 로고 이미지를 추가하였습니다
만료시간을 설정하는 변수의 단위가 서로 일치하지 않던 문제를 수정하였습니다
기존 비밀번호 변경 API가 정수형 매개변수를 요구하던 본래 요구사항에서 문자열 매개변수를 요구하게 되며 이를 반영하였습니다
이메일 전송 실패 시 반환할 정보를 구성하는 메서드를 추가 구현하였습니다
요청이 올바르지 않을 시 JWT 필터에서 이를 거르도록 구조를 변경하였습니다
기존에 반환값이 없도록 설정되었던 메서드들을 본문이 없는 메세지를 반환하도록 구성하였습니다
설정되지 않은 엔드포인트로의 요청을 전부 허용하도록 설정하였습니다
요구사항에 따라 이메일 길이 검증 조건을 추가하여 강화하였습니다
프로젝트 컨벤션에 맞게 테스트 표시명 형식을 변경하였습니다
인증/인가 비즈니스 로직 Use Case 테스트코드를 추가하였습니다
@snowykte0426 snowykte0426 added the 🔨 Type: Refector 코드 리펙토링 label Mar 28, 2025
@snowykte0426 snowykte0426 requested a review from Copilot March 28, 2025 01:30
@snowykte0426 snowykte0426 self-assigned this Mar 28, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the authentication and authorization logic by reorganizing packages, renaming and removing outdated classes, and introducing new use cases to align with the API specification. Key changes include:

  • Removal of obsolete classes such as EmailVerification, JwtToken, JwtService, EmailVerificationService, CustomUserDetailsService, AuthService, and AuthPort.
  • Consolidation and renaming of persistence adapters and ports to streamline authentication and authorization processes.
  • Introduction of new use cases (SignUpUseCase, SignInUseCase, RefreshUseCase, SendAuthenticationEmailUseCase, VerifyEmailUseCase) and a dedicated AuthApplicationAdapter to coordinate these flows.

Reviewed Changes

Copilot reviewed 74 out of 75 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
EmailVerification.java Entire file removed as part of the refactoring of email verification logic.
AuthenticationPersistenceAdapter.java Package relocation to better reflect its role in authentication persistence.
AuthCodePersistenceAdapter.java Renamed and repurposed adapter to manage auth code persistence.
JwtToken.java Entire file removed to phase out outdated JWT token representation.
GenerationAuthCode.java New utility added for generating authentication codes.
VerifyEmailUseCase.java New use case added to encapsulate email verification logic.
SignUpUseCase.java New use case handling sign-up logic with updated authentication checks and generation calculation.
SignInUseCase.java New use case for sign-in logic with JWT issuance.
SendAuthenticationEmailUseCase.java New use case for managing email sending and authentication attempts.
RefreshUseCase.java New use case for refreshing authentication tokens.
AuthApplicationPort.java, AuthApplicationAdapter.java New adapter and port to expose auth-related operations into the inbound layer.
Files not reviewed (1)
  • .env.example: Language not supported
Comments suppressed due to low confidence (1)

src/main/java/com/ampersand/groom/domain/auth/application/usecase/SignUpUseCase.java:48

  • [nitpick] The regex '\d{2}' might capture unintended two-digit sequences from the email. Consider using a more specific pattern or adding additional email format validation to ensure correct generation calculation.
Matcher matcher = Pattern.compile("\\d{2}").matcher(email);

기존 단순한 함수로 값을 추출하던 방식에서 조금 더 보안적으로 안전한 방식을 채택하였습니다
@snowykte0426 snowykte0426 merged commit 11b0795 into develop Mar 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 Type: Refector 코드 리펙토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants