-
Notifications
You must be signed in to change notification settings - Fork 0
[Release] v1.0.1 – ADMIN 계정 세팅 #139
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
Conversation
[CHORE] ApplicationRunner 를 활용한 admin 계정 생성
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.
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
-
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. ↩
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.
Code Review
안녕하세요. ADMIN 계정 생성을 위한 초기화 로직 추가 및 관련 설정 변경 PR에 대한 리뷰입니다. 전반적으로 ADMIN 계정을 안전하게 생성하기 위한 좋은 시도라고 생각합니다. 쿠버네티스 및 애플리케이션 설정 변경은 올바르게 적용되었습니다. 새로 추가된 AdminAccountInitializer 클래스에 대해 몇 가지 개선점을 제안했습니다. 주요 내용은 다음과 같습니다:
- 의존성 주입 방식을 생성자 주입으로 통일하여 클래스의 불변성을 높이는 방안
- 보안 강화를 위해 로그에 관리자 사용자 이름을 남기지 않도록 수정
- 코드 가독성을 위해 중복된
@Transactional어노테이션 제거 application-prod.yml파일의 끝에 개행 문자를 추가하는 스타일 개선
자세한 내용은 각 파일의 인라인 코멘트를 확인해주세요.
| private final AdminRepository adminRepository; | ||
| private final PasswordEncoder passwordEncoder; | ||
|
|
||
| @Value("${admin.username}") | ||
| private String adminUsername; | ||
| @Value("${admin.password}") | ||
| private String adminPassword; |
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.
필드 주입 대신 생성자 주입을 사용하여 모든 의존성을 주입하는 것이 좋습니다. 이렇게 하면 모든 필드를 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 |
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.
| String encodedPassword = passwordEncoder.encode(adminPassword); | ||
| Admin admin = new Admin(adminUsername, encodedPassword); | ||
| adminRepository.save(admin); | ||
| log.info("Admin account created: {}", adminUsername); |
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.
|
|
||
| admin: | ||
| username: ${CHERRY_ADMIN_ID} | ||
| password: ${CHERRY_ADMIN_PW} |
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.
관련 Issue (필수)
주요 변경 사항 (필수)
리뷰어 참고 사항
없음
추가 정보
없음
PR 작성 체크리스트 (필수)