구글 OAuth 로그인 코드 리팩토링 #8
Merged
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.
📣 Related Issue
📝 Summary
1. 서비스 클래스 오타
-> MemeberService -> MemberService 오타 수정
2. 스프링시큐리티 세션 정책 명시
-> JWT를 쓰더라도 스프링 시큐리티는 기본적으로 세션을 생성하기에 무상태 설정 추가
http.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS));3. JwtTokenProvider
-> Gradle: io.jsonwebtoken:jjwt-api:0.12.5 버전에서 Jwt.parserBuilder() Deprecated가 되었다고 함
Jwts.parser()/Jwts.builder()사용builder()→ 토큰 만들 때 쓰는 것 (클레임·만료시간 설정 후 compact() 호출)parser()→ 토큰 검증/파싱할 때 쓰는 것 (키로 검증하고 parseSignedClaims(...)로 클레임 추출)Jwts.claims()→ Builder 반환setXxx→xxx(예:subject)build()호출parser()+verifyWith)4. RestTemplate -> WebClient 수정
-> Spring 5.0 이후부터는 RestTemplate이 Deprecated 예정이라 WebClient로 교체하는걸 권장
5. 예외처리
-> 커스텀 예외 처리 사용함
6. 레이어드 아키텍처 분리 모호
->
@Valid사용하여 에러처리 + controller & service 역할 확실히 분리7. 구글 관련 서비스 분리
->
MemberService.java내 구글 OAuth 관련 코드OAuthService.java만들어서 분리시킴8. PrincipalDetails
-> PrincipalDetails는 원래 Spring Security + OAuth2 세션 기반 인증에서 사용, 현재 우리는 JWT 방식 사용 중이므로 삭제
📬 Reference