-
Notifications
You must be signed in to change notification settings - Fork 1
⚙️ ON-226 프로파일에 따른 인증로직 분리 #84
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
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9b93c76
feat: 토스 관련 로직을 거치지 않는 로컬 목업필터 구현
wonjuneee a5c826b
refactor: 전략 패턴을 적용하여 세부필터 로직 추출
wonjuneee a930c9d
refactor: 불필요한 로깅 제거
wonjuneee 937867f
fix: MemberStatus 추가
wonjuneee 03ad6df
chore: 코드 indent 수정
wonjuneee 516a8e2
feat: 토스 관련 로직을 거치지 않는 로컬 목업필터 구현
wonjuneee 0ddac61
refactor: 전략 패턴을 적용하여 세부필터 로직 추출
wonjuneee 5e07b52
refactor: 불필요한 로깅 제거
wonjuneee 06fa454
fix: MemberStatus 추가
wonjuneee 373adff
chore: 코드 indent 수정
wonjuneee 4ec6389
Merge remote-tracking branch 'origin/feat/ON-226' into feat/ON-226
wonjuneee 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
8 changes: 8 additions & 0 deletions
8
src/main/java/OneQ/OnSurvey/global/auth/application/strategy/AuthStrategy.java
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,8 @@ | ||
| package OneQ.OnSurvey.global.auth.application.strategy; | ||
|
|
||
| import OneQ.OnSurvey.domain.member.Member; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
|
|
||
| public interface AuthStrategy { | ||
| Member authenticate(HttpServletRequest request); | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
src/main/java/OneQ/OnSurvey/global/auth/application/strategy/LocalAuthStrategy.java
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,31 @@ | ||
| package OneQ.OnSurvey.global.auth.application.strategy; | ||
|
|
||
| import OneQ.OnSurvey.domain.member.Member; | ||
| import OneQ.OnSurvey.domain.member.value.MemberStatus; | ||
| import OneQ.OnSurvey.domain.member.value.Role; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Slf4j | ||
| @Profile({"local", "docker-local"}) | ||
| @Component | ||
| @NoArgsConstructor | ||
| public class LocalAuthStrategy implements AuthStrategy { | ||
wonjuneee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| static { | ||
| log.info("===== LocalAuthStrategy authenticate called ====="); | ||
| } | ||
wonjuneee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @Override | ||
| public Member authenticate(HttpServletRequest request) { | ||
| return Member.builder() | ||
| .id(1L) | ||
| .userKey(1234567890L) | ||
| .role(Role.ROLE_MEMBER) | ||
| .status(MemberStatus.ACTIVE) | ||
| .build(); | ||
| } | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
src/main/java/OneQ/OnSurvey/global/auth/application/strategy/TossAuthStrategy.java
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,33 @@ | ||
| package OneQ.OnSurvey.global.auth.application.strategy; | ||
|
|
||
| import OneQ.OnSurvey.domain.member.Member; | ||
| import OneQ.OnSurvey.domain.member.repository.MemberRepository; | ||
| import OneQ.OnSurvey.global.auth.application.AuthUseCase; | ||
| import OneQ.OnSurvey.global.infra.toss.common.dto.auth.LoginMeResponse; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.security.authentication.BadCredentialsException; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Slf4j | ||
| @Profile("prod") | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class TossAuthStrategy implements AuthStrategy { | ||
wonjuneee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private final AuthUseCase authUseCase; | ||
| private final MemberRepository memberRepository; | ||
|
|
||
| static { | ||
| log.info("===== ProdAuthStrategy authenticate called ====="); | ||
| } | ||
wonjuneee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @Override | ||
| public Member authenticate(HttpServletRequest request) { | ||
| LoginMeResponse.Success me = authUseCase.authenticateWithToss(request); | ||
| return memberRepository.findMemberByUserKey(me.userKey()) | ||
| .orElseThrow(() -> new BadCredentialsException("member not found")); | ||
| } | ||
| } | ||
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
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.