[8 주차] 정용환 / Chapter 8. Spring Security - Security 구조, 폼 로그인 - #40
hwahwahwan wants to merge 6 commits into
Conversation
| .exceptionHandling(exception -> exception | ||
| .accessDeniedHandler(customAccessDenied()) // 403 응답 통일 | ||
| .authenticationEntryPoint(customEntryPoint()) // 401 응답 통일 | ||
| ); | ||
| return http.build(); | ||
| } | ||
|
|
||
| @Bean | ||
| public PasswordEncoder passwordEncoder() { | ||
| return new BCryptPasswordEncoder(); | ||
| } | ||
|
|
||
| @Bean | ||
| public CustomAccessDenied customAccessDenied() { | ||
| return new CustomAccessDenied(); | ||
| } | ||
|
|
||
| @Bean | ||
| public CustomEntryPoint customEntryPoint() { | ||
| return new CustomEntryPoint(); | ||
| } |
There was a problem hiding this comment.
저는 단순 Handler 클래스라서 직접 생성했는데, 스프링 방식과 확장성을 고려하면 Bean 등록 후 주입받는 구조도 좋을 것 같겠네요.
| public static Member toMember(MemberReqDTO.SignUp dto, String encodedPassword) { | ||
| return Member.builder() | ||
| .email(dto.email()) | ||
| .password(encodedPassword) | ||
| .name(dto.name()) | ||
| .gender(dto.gender() != null | ||
| ? Gender.valueOf(dto.gender().toUpperCase()) | ||
| : Gender.NONE) | ||
| .birthDate(dto.birthDate()) | ||
| .address(dto.address()) | ||
| .snsType(dto.snsType()) | ||
| .build(); | ||
| } |
There was a problem hiding this comment.
컨버터가 매개변수로 암호화된 패스워드를 받게 되면 컨버터 자체의 책임이 애매해 질 수 있을 것 같습니다. 암호화된 패스워드는 서비스 로직 쪽에서 처리하는 게 맞는 방향인 것 같습니다.
| @@ -20,22 +19,4 @@ public record SignUp( | |||
| List<String> foodTypes, | |||
| SnsType snsType | |||
There was a problem hiding this comment.
현재는 snsType 만 존재하는데 소셜 로그인을 고려하신다면 소셜 uid 도 함께 관리하는 게 좋을 것 같습니다. 실제 소셜 로그인에서는 일반적으로 (provider, providerUserId) 조합으로 회원을 식별하는 경우가 많다고 알고 있습니다.
|
|
||
| public abstract class BaseSecurityHandler { | ||
|
|
||
| private static final ObjectMapper objectMapper = new ObjectMapper(); |
There was a problem hiding this comment.
static으로 직접 생성한 ObjectMapper 대신 스프링의 싱글톤 빈을 주입받아 사용하도록 한다면, 형석님이 리뷰 달아주신 빈 주입 구조와도 잘 맞물릴 것 같습니다..!!
| .gender(dto.gender() != null | ||
| ? Gender.valueOf(dto.gender().toUpperCase()) | ||
| : Gender.NONE) |
There was a problem hiding this comment.
제가 이번에 미션을 하면서 대소문자 구분이 안되는 경우랑 null 값이 들어와서 IllegalArgumentException으로 삽질을 좀 했었는데, 용환님이 작성하신걸 보니까 삼항 연산자로 null 방어를 하고, .toUpperCase()로 잘 매핑하신 것 같습니다.

🔗 Issue Number
📝 개요
🚀 주요 변경 사항
🖼️ 실행 결과 (Screenshots)
💬 고민 및 질문
생각보다 필터 구조에 대해 완벽하게 이해하지 못한 것 같습니다 틀린 내용 있으면 피드백 부탁드려요
✅ 실습 체크리스트
⚙️ 환경 및 컨벤션 체크 (Final Check)