Skip to content

Conversation

@Ogu1208
Copy link
Contributor

@Ogu1208 Ogu1208 commented Sep 11, 2025

관련 Issue (필수)

  • close #136

주요 변경 사항 (필수)

리뷰어 참고 사항

없음

추가 정보

없음

PR 작성 체크리스트 (필수)

  • 제목이 Issue와 동일함을 확인했습니다.
  • 리뷰어를 지정했습니다.
  • 프로젝트를 연결했습니다.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @Ogu1208, 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은 애플리케이션의 프로덕션 환경에 관리자 계정을 설정하는 기능을 도입합니다. Kubernetes 배포에 필요한 환경 변수를 추가하고, 애플리케이션 시작 시 해당 변수를 사용하여 관리자 계정을 초기화하는 로직을 구현함으로써, 시스템의 초기 설정 및 보안을 강화합니다.

Highlights

  • 관리자 계정 환경 변수 추가: Kubernetes 배포 설정(k8s/depl_svc.yml)에 관리자 ID(CHERRY_ADMIN_ID)와 비밀번호(CHERRY_ADMIN_PW)를 cherry-secrets에서 가져오도록 환경 변수가 추가되었습니다.
  • 관리자 계정 초기화 로직 구현: 프로덕션 환경에서 애플리케이션 시작 시 관리자 계정을 자동으로 생성하는 AdminAccountInitializer 클래스가 추가되었습니다. 이 로직은 계정이 이미 존재하는 경우 중복 생성을 방지하고 비밀번호를 안전하게 인코딩합니다.
  • 프로덕션 환경 설정 업데이트: application-prod.yml 파일에 admin.username과 admin.password 속성이 추가되어, Kubernetes 배포에서 주입된 환경 변수 값을 사용하도록 구성되었습니다.
Using Gemini Code Assist

The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Ogu1208 Ogu1208 added this to 💙 BE Sep 11, 2025
@Ogu1208 Ogu1208 added this to the 2차 MVP 개발 (9.6 ~ 9.10) milestone Sep 11, 2025
@Ogu1208 Ogu1208 merged commit e5746d0 into main Sep 11, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this to Done in 💙 BE Sep 11, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

안녕하세요. ADMIN 계정 생성을 위한 초기화 로직 추가 및 관련 설정 변경 PR에 대한 리뷰입니다. 전반적으로 ADMIN 계정을 안전하게 생성하기 위한 좋은 시도라고 생각합니다. 쿠버네티스 및 애플리케이션 설정 변경은 올바르게 적용되었습니다. 새로 추가된 AdminAccountInitializer 클래스에 대해 몇 가지 개선점을 제안했습니다. 주요 내용은 다음과 같습니다:

  • 의존성 주입 방식을 생성자 주입으로 통일하여 클래스의 불변성을 높이는 방안
  • 보안 강화를 위해 로그에 관리자 사용자 이름을 남기지 않도록 수정
  • 코드 가독성을 위해 중복된 @Transactional 어노테이션 제거
  • application-prod.yml 파일의 끝에 개행 문자를 추가하는 스타일 개선
    자세한 내용은 각 파일의 인라인 코멘트를 확인해주세요.

Comment on lines +23 to +29
private final AdminRepository adminRepository;
private final PasswordEncoder passwordEncoder;

@Value("${admin.username}")
private String adminUsername;
@Value("${admin.password}")
private String adminPassword;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

필드 주입 대신 생성자 주입을 사용하여 모든 의존성을 주입하는 것이 좋습니다. 이렇게 하면 모든 필드를 final로 선언하여 클래스의 불변성을 높이고 테스트 용이성을 개선할 수 있습니다. 아래와 같이 명시적인 생성자를 추가하고, 17행의 @RequiredArgsConstructor는 제거해주세요.

	private final AdminRepository adminRepository;
	private final PasswordEncoder passwordEncoder;
	private final String adminUsername;
	private final String adminPassword;

	public AdminAccountInitializer(
		AdminRepository adminRepository,
		PasswordEncoder passwordEncoder,
		@Value("${admin.username}") String adminUsername,
		@Value("${admin.password}") String adminPassword
	) {
		this.adminRepository = adminRepository;
		this.passwordEncoder = passwordEncoder;
		this.adminUsername = adminUsername;
		this.adminPassword = adminPassword;
	}

private String adminPassword;

@Override
@Transactional
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

클래스 레벨에 @Transactional 어노테이션이 이미 선언되어 있으므로(19행), run 메서드에 다시 선언할 필요가 없습니다. 중복되는 어노테이션은 코드의 가독성을 해칠 수 있으므로 이 줄을 제거하는 것이 좋습니다.

String encodedPassword = passwordEncoder.encode(adminPassword);
Admin admin = new Admin(adminUsername, encodedPassword);
adminRepository.save(admin);
log.info("Admin account created: {}", adminUsername);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

관리자 계정 이름(adminUsername)을 로그에 남기는 것은 잠재적인 정보 노출 위험이 있습니다. 민감한 정보는 로그에 기록하지 않는 것이 보안상 좋은 습관입니다. 계정 생성 사실 자체만 로그로 남기도록 변경하는 것을 권장합니다.

			log.info("Admin account created successfully.");


admin:
username: ${CHERRY_ADMIN_ID}
password: ${CHERRY_ADMIN_PW}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

파일의 마지막에 개행 문자(newline)를 추가하는 것이 좋습니다. 많은 텍스트 편집기와 버전 관리 시스템(Git 등)에서 이는 표준적인 관례이며, 파일 끝에 내용이 추가될 때 예기치 않은 동작을 방지할 수 있습니다. 이 줄 다음에 빈 줄을 하나 추가해주세요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants