-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] OAuth Spring Security 적용 #43
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
Open
toychip
wants to merge
24
commits into
main
Choose a base branch
from
feat/#42-spring-security-oauth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+854
−191
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c3785d6
feat: Spring Security 및 OAuth 관련 의존성 추가 (#42)
toychip e58def8
feat: Member 도메인 모델 OAuth 필드로 변경 (#42)
toychip 5fe1182
feat: Member 영속성 계층 OAuth 필드 반영 (#42)
toychip 6a8aca6
feat: OAuth output port 및 ExceptionCode 추가 (#42)
toychip 11ce6c2
feat: Kakao, Google, Apple OAuth 어댑터 구현 (#42)
toychip 0c4f905
feat: Spring Security 인프라 구성 (#42)
toychip 23be245
feat: AuthController 소셜 로그인 엔드포인트 전환 (#42)
toychip ea0c7d2
feat: AuthService / MemberService 책임 분리 (#42)
toychip 255158b
refactor: 기존 서블릿 필터 인증 코드 제거 및 SecurityContextHolder 전환 (#42)
toychip 2352de6
test: OAuth 소셜 로그인 전환에 따른 테스트 수정 (#42)
toychip 43134d6
refactor: ktlint 파일명-클래스명 불일치 수정 (#42)
toychip f25781c
refactor: ktlint 파일명-클래스명 불일치 수정 (#42)
toychip 5478519
fix: JwtSecurityFilter에서 filterChain.doFilter를 try 밖으로 분리 (#42)
toychip a423633
fix: JwtAuthenticationProvider에서 모든 예외를 BadCredentialsException으로 변환 …
toychip da2553e
fix: SecurityFilterChain에 @Order 추가하여 평가 순서 보장 (#42)
toychip 3194d0a
fix: SecurityPaths 공개 경로 범위 축소 (#42)
toychip a9981ec
fix: JwtTokenProvider에 IllegalArgumentException 예외 처리 추가 (#42)
toychip 7da5274
fix: Apple ID token issuer/audience 검증 추가 (#42)
toychip fc5db1f
fix: MemberAdapter 동시 요청 중복 회원 저장 방지 (#42)
toychip 2510ef5
fix: AuthService 로그에서 민감 식별자 제거 (#42)
toychip 2cfc41a
refactor: 중복 인덱스 및 미사용 findByEmail 제거 (#42)
toychip 493375e
fix: AppleOAuthAdapter 토큰 파싱 예외 처리 및 providerId 검증 추가 (#42)
toychip bd33396
fix: 예외 타입 포맷에 맞게 수정 (#43)
toychip a37f999
fix: 예외 타입 포맷에 맞게 수정 (#43)
toychip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
40 changes: 40 additions & 0 deletions
40
linktrip-application/src/main/kotlin/com/linktrip/application/domain/member/MemberService.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package com.linktrip.application.domain.member | ||
|
|
||
| import com.linktrip.application.port.output.auth.OAuthInfo | ||
| import com.linktrip.application.port.output.persistence.MemberPort | ||
| import mu.KotlinLogging | ||
| import org.springframework.stereotype.Service | ||
| import org.springframework.transaction.annotation.Transactional | ||
|
|
||
| private val logger = KotlinLogging.logger {} | ||
|
|
||
| @Service | ||
| class MemberService( | ||
| private val memberPort: MemberPort, | ||
| ) { | ||
| @Transactional | ||
| fun findOrCreateByOAuth( | ||
| providerType: ProviderType, | ||
| oAuthInfo: OAuthInfo, | ||
| ): MemberLoginResult { | ||
| memberPort.findByProviderTypeAndProviderId(providerType, oAuthInfo.providerId) | ||
| ?.let { return MemberLoginResult(member = it, isNewMember = false) } | ||
|
|
||
| val newMember = | ||
| memberPort.save( | ||
| Member.create( | ||
| email = oAuthInfo.email, | ||
| providerType = providerType, | ||
| providerId = oAuthInfo.providerId, | ||
| ), | ||
| ) | ||
|
|
||
| logger.info { "신규 회원 생성: memberId=${newMember.id}, provider=$providerType" } | ||
| return MemberLoginResult(member = newMember, isNewMember = true) | ||
| } | ||
|
|
||
| data class MemberLoginResult( | ||
| val member: Member, | ||
| val isNewMember: Boolean, | ||
| ) | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
linktrip-application/src/main/kotlin/com/linktrip/application/domain/member/ProviderType.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.linktrip.application.domain.member | ||
|
|
||
| enum class ProviderType { | ||
| KAKAO, | ||
| GOOGLE, | ||
| APPLE, | ||
| } |
7 changes: 6 additions & 1 deletion
7
linktrip-application/src/main/kotlin/com/linktrip/application/port/input/AuthUseCase.kt
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
9 changes: 9 additions & 0 deletions
9
linktrip-application/src/main/kotlin/com/linktrip/application/port/output/auth/OAuthInfo.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.linktrip.application.port.output.auth | ||
|
|
||
| import com.linktrip.application.domain.member.ProviderType | ||
|
|
||
| data class OAuthInfo( | ||
| val providerType: ProviderType, | ||
| val providerId: String, | ||
| val email: String?, | ||
| ) |
9 changes: 9 additions & 0 deletions
9
linktrip-application/src/main/kotlin/com/linktrip/application/port/output/auth/OAuthPort.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.linktrip.application.port.output.auth | ||
|
|
||
| import com.linktrip.application.domain.member.ProviderType | ||
|
|
||
| interface OAuthPort { | ||
| fun getProviderType(): ProviderType | ||
|
|
||
| fun requestUserInfo(accessToken: String): OAuthInfo | ||
| } |
6 changes: 5 additions & 1 deletion
6
...pplication/src/main/kotlin/com/linktrip/application/port/output/persistence/MemberPort.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| package com.linktrip.application.port.output.persistence | ||
|
|
||
| import com.linktrip.application.domain.member.Member | ||
| import com.linktrip.application.domain.member.ProviderType | ||
|
|
||
| interface MemberPort { | ||
| fun findBySerialNumber(serialNumber: String): Member? | ||
| fun findByProviderTypeAndProviderId( | ||
| providerType: ProviderType, | ||
| providerId: String, | ||
| ): Member? | ||
|
|
||
| fun save(member: Member): Member | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.