[기믕] Chapter 8. Spring Security - Security 구조, 폼 로그인#120
Open
ennseo wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Spring Security를 프로젝트에 도입해 폼 로그인 기반 인증을 적용하고, 회원가입 시 비밀번호를 BCrypt로 인코딩하여 저장하도록 확장한 PR입니다. 또한 인증/인가 실패 시 응답 포맷을 기존 ApiResponse 규격으로 통일하기 위한 핸들러를 추가했습니다.
Changes:
- Spring Security(formLogin) 설정 및 Public/Private API 접근 제어 추가
- 인증/인가 실패(401/403) 시
ApiResponse.onFailure(...)로 응답 통일하는 핸들러 추가 - 회원가입 시 비밀번호 저장(BCrypt 인코딩) 및 이메일 기반 조회(
findByEmail) 지원
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/example/umc10th/global/security/service/CustomUserDetailsService.java | 이메일로 회원 조회 후 UserDetails 제공 |
| src/main/java/com/example/umc10th/global/security/handler/CustomAuthenticationEntryPoint.java | 미인증(401) 시 공통 에러 응답(JSON) 반환 |
| src/main/java/com/example/umc10th/global/security/handler/CustomAccessDeniedHandler.java | 접근 거부(403) 시 공통 에러 응답(JSON) 반환 |
| src/main/java/com/example/umc10th/global/security/entity/AuthMember.java | Member를 UserDetails로 감싸는 어댑터 |
| src/main/java/com/example/umc10th/global/config/SecurityConfig.java | SecurityFilterChain, allowlist, formLogin/logout, 예외 핸들러 구성 |
| src/main/java/com/example/umc10th/domain/member/service/MemberService.java | 회원가입 시 비밀번호 BCrypt 인코딩 저장 |
| src/main/java/com/example/umc10th/domain/member/repository/MemberRepository.java | 이메일 조회용 findByEmail 추가 |
| src/main/java/com/example/umc10th/domain/member/entity/Member.java | password 컬럼 추가 |
| build.gradle | Spring Security 의존성 추가 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+24
to
+28
|
|
||
| Member member = memberRepository.findByEmail(username) | ||
| .orElseThrow(() -> new MemberException(MemberErrorCode.MEMBER_NOT_FOUND)); | ||
|
|
||
| return new AuthMember(member); |
Comment on lines
+11
to
+22
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { | ||
|
|
||
| @Override | ||
| public void commence( | ||
| HttpServletRequest request, | ||
| HttpServletResponse response, | ||
| AuthenticationException authException | ||
| ) throws IOException { | ||
| ObjectMapper objectMapper = new ObjectMapper(); |
Comment on lines
+22
to
+23
| ObjectMapper objectMapper = new ObjectMapper(); | ||
| BaseErrorCode code = GeneralErrorCode.FORBIDDEN; |
Comment on lines
9
to
+10
| public interface MemberRepository extends JpaRepository<Member, Long> { | ||
| Optional<Member> findByEmail(String email); |
Comment on lines
+29
to
+33
| http | ||
| .csrf(AbstractHttpConfigurer::disable) | ||
| .authorizeHttpRequests(requests -> requests | ||
| .requestMatchers(allowUris).permitAll() | ||
| .anyRequest().authenticated() |
Comment on lines
+31
to
+34
| .authorizeHttpRequests(requests -> requests | ||
| .requestMatchers(allowUris).permitAll() | ||
| .anyRequest().authenticated() | ||
| ) |
sekong11
reviewed
May 25, 2026
sekong11
left a comment
There was a problem hiding this comment.
Spring Security 구조에 맞춰 잘 짜신 것 같아요 고생하셨어요!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✏️ 작업 내용
#️⃣ 연관된 이슈
closes #116
💡 함께 공유하고 싶은 부분
🤔 질문
✅ 워크북 체크리스트
✅ 컨벤션 체크리스트
📌 주안점