Conversation
related_to : #7 ## 📝 작업 내용 자동 배포를 위한 CD 추가 ## ✅ 변경 사항 - [x] cd-prod.yml 파일 추가 - [x] 서버에 .env 파일 추가 (노션 참고) ## 📷 스크린샷 (선택) ## 💬 리뷰어에게 Main 브랜치에 pr이 올라가야 작동하기 때문에, dev 브랜치 그대로 PR 날립니다. 환경변수는 서버에 직접 .env 파일로 올려두었습니다. application-prod.yml을 기준으로 작동합니다. (→ SPRING_PROFILES_ACTIVE=prod) --------- Co-authored-by: Yoonchul Chung <84674889+Yoonchulchung@users.noreply.github.com> Co-authored-by: yoonchulchung <yoonchul005@gmail.com>
Summary of ChangesHello @Yoonchulchung, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 Main 브랜치 병합 시 발생할 수 있는 충돌을 해결하기 위해 병합 전략을 변경하고, 애플리케이션의 핵심 기반을 강화하는 데 중점을 둡니다. JWT 기반의 Spring Security를 도입하여 강력한 인증 및 권한 부여 시스템을 구축했으며, Swagger를 통해 API 문서화를 자동화하고, 전역 예외 처리기를 구현하여 애플리케이션의 견고성을 높였습니다. 또한, Checkstyle을 추가하여 코드 품질을 일관되게 유지하고, Docker 환경 설정을 개선하여 개발 및 배포 프로세스를 간소화했습니다. 이러한 변경 사항들은 프로젝트의 안정성, 유지보수성 및 개발 효율성을 크게 향상시킬 것입니다. Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이 PR은 머지 전략 변경에 대한 것이라고 되어 있지만, 실제로는 스프링 부트 애플리케이션의 전체적인 초기 설정을 포함하고 있습니다. 보안, JWT, JPA, Docker, Swagger, Checkstyle 등 많은 기능이 추가되었습니다. PR의 제목과 설명을 실제 변경 내용에 맞게 수정하는 것이 좋겠습니다. 전반적인 설정은 잘 되어 있으나, 몇 가지 중요한 수정 사항이 있습니다. 특히 JPA Auditing 설정 누락, 중복된 의존성, 사용되지 않는 파라미터 등의 문제를 수정해야 합니다. 자세한 내용은 각 파일에 대한 리뷰 코멘트를 참고해주세요.
| @Getter | ||
| @MappedSuperclass | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| @NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) | ||
| public abstract class BaseEntity { |
There was a problem hiding this comment.
| testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
| testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
|
|
||
| // Test dependencies | ||
| testRuntimeOnly 'com.h2database:h2' | ||
| testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
| testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
| testImplementation 'org.springframework.security:spring-security-test' | ||
| testRuntimeOnly 'org.junit.platform:junit-platform-launcher' |
There was a problem hiding this comment.
| this.isDeleted = false; | ||
| } | ||
|
|
||
| public void softDelete(Integer deletedBy, LocalDateTime deletedAt) { |
There was a problem hiding this comment.
| public SecurityFilterChain securityFilterChain(HttpSecurity http, CustomAuthEntryPoint customAuthEntryPoint, CustomAccessDeniedHandler customAccessDeniedHandler) throws Exception { | ||
| http | ||
| .cors(cors -> cors.configurationSource(corsConfigurationSource())) | ||
| .csrf(csrf -> csrf.disable()) |
There was a problem hiding this comment.
JWT를 사용한 인증 방식에서는 서버가 세션을 유지할 필요가 없으므로, 세션 관리 정책을 STATELESS로 설정하는 것이 중요합니다. 이렇게 하면 불필요한 세션 생성을 막고 메모리 사용을 줄일 수 있으며, 완전한 무상태(stateless) 아키텍처를 유지할 수 있습니다.
| .csrf(csrf -> csrf.disable()) | |
| .csrf(csrf -> csrf.disable()) | |
| .sessionManagement(session -> session.sessionCreationPolicy(org.springframework.security.config.http.SessionCreationPolicy.STATELESS)) |
| environment: | ||
| - SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/myapp_db?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul | ||
| - SPRING_DATASOURCE_USERNAME=admin | ||
| - SPRING_DATASOURCE_PASSWORD=secret | ||
| - SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.cj.jdbc.Driver | ||
| - SPRING_REDIS_HOST=redis | ||
| - SPRING_REDIS_PORT=6379 | ||
| - SPRING_PROFILES_ACTIVE=dev | ||
|
|
||
| SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL} | ||
| SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME} | ||
| SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD} | ||
| SPRING_DATASOURCE_DRIVER_CLASS_NAME: ${SPRING_DATASOURCE_DRIVER_CLASS_NAME} | ||
| SPRING_REDIS_HOST: ${SPRING_REDIS_HOST} | ||
| SPRING_REDIS_PORT: ${SPRING_REDIS_PORT} | ||
| SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE} |
| .claim("role", role) | ||
| .issuedAt(new Date(now)) | ||
| .expiration(new Date(now + expireMillis)) | ||
| .signWith(secretKey, SignatureAlgorithm.HS256) |
There was a problem hiding this comment.
signWith(secretKey, SignatureAlgorithm.HS256) 메소드는 jjwt 라이브러리에서 더 이상 사용되지 않는(deprecated) 방식입니다. secretKey가 HS256 알고리즘을 사용하도록 생성되었으므로, 알고리즘을 명시적으로 지정할 필요가 없습니다. signWith(secretKey)만 사용하도록 수정하는 것이 좋습니다. 이렇게 하면 코드가 더 간결해지고 최신 라이브러리 버전에 맞게 됩니다.
| .signWith(secretKey, SignatureAlgorithm.HS256) | |
| .signWith(secretKey) |
| "잘못된 요청입니다."), | ||
|
|
||
| INVALID_DATA(HttpStatus.BAD_REQUEST, | ||
| "COMMON4001_2", |
related_to : #7
📝 작업 내용
Main으로 merge할 때는 Squash가 아니라 기본 Merge 방법을 사용해야 Conflict가 발생하지 않습니다. 이거 생각을 못하고 있었어요
✅ 변경 사항