From 8dc1dce764e2e9beb6a335ecf51bff8c7aa6e2b9 Mon Sep 17 00:00:00 2001 From: seokjin8678 Date: Fri, 7 Jun 2024 18:27:40 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20auth=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EB=82=B4=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/AdminAuthenticationArgumentResolver.java | 1 + .../auth/AnnotationAuthorizationInterceptor.java | 6 +++--- .../festago/auth/FixedAuthorizationInterceptor.java | 3 ++- .../auth/MemberAuthenticationArgumentResolver.java | 1 + .../java/com/festago/auth/RoleArgumentResolver.java | 1 + .../com/festago/auth/application/OAuth2Client.java | 11 ----------- .../application/command/MemberAuthCommandService.java | 6 +++--- .../application/command/MemberAuthFacadeService.java | 10 +++++----- .../main/java/com/festago/auth/config/AuthConfig.java | 4 ++-- .../java/com/festago/auth/config/LoginConfig.java | 8 ++++---- .../auth/{ => domain}/AuthenticateContext.java | 3 +-- .../java/com/festago/auth/domain/OAuth2Client.java | 10 ++++++++++ .../auth/{application => domain}/OAuth2Clients.java | 4 ++-- .../java/com/festago/auth/domain/OpenIdClient.java | 2 ++ .../java/com/festago/auth/domain/OpenIdClients.java | 1 + .../main/java/com/festago/auth/domain/UserInfo.java | 1 + .../v1/{LoginResult.java => MemberLoginResult.java} | 2 +- .../com/festago/auth/dto/v1/OAuth2LoginV1Request.java | 2 +- .../com/festago/auth/dto/v1/OpenIdLoginV1Request.java | 2 +- .../AdminAuthenticationTokenExtractor.java | 2 ++ .../AdminAuthenticationTokenProvider.java | 3 +-- .../CompositeAuthenticationTokenExtractor.java | 2 ++ .../MemberAuthenticationTokenExtractor.java | 2 ++ .../MemberAuthenticationTokenProvider.java | 3 +-- .../{ => jwt}/AdminAuthenticationClaimsExtractor.java | 6 ++---- .../{ => jwt}/AuthenticationClaimsExtractor.java | 2 +- .../auth/infrastructure/{ => jwt}/JwtTokenParser.java | 2 +- .../MemberAuthenticationClaimsExtractor.java | 6 ++---- .../{ => jwt}/TokenProviderTemplate.java | 2 +- .../infrastructure/oauth2/FestagoOAuth2Client.java | 4 ++-- .../auth/infrastructure/oauth2/KakaoOAuth2Client.java | 4 ++-- .../auth/infrastructure/openid/AppleOpenIdClient.java | 6 ++---- .../infrastructure/openid/FestagoOpenIdClient.java | 2 +- .../auth/infrastructure/openid/KakaoOpenIdClient.java | 2 +- .../{ => web}/CompositeHttpRequestTokenExtractor.java | 3 +-- .../{ => web}/CookieHttpRequestTokenExtractor.java | 3 +-- .../{ => web}/HeaderHttpRequestTokenExtractor.java | 3 +-- .../web}/HttpRequestTokenExtractor.java | 2 +- .../auth/presentation/v1/MemberAuthV1Controller.java | 2 +- .../common/handler/GlobalExceptionHandler.java | 2 +- .../member/config/DefaultNicknamePolicyConfig.java | 2 +- .../main/java/com/festago/member/domain/Member.java | 2 -- .../festago/{auth => member}/domain/SocialType.java | 2 +- .../infrastructure/SocialTypeConverter.java | 4 ++-- .../festago/member/repository/MemberRepository.java | 2 +- .../command/MemberAuthCommandServiceTest.java | 2 +- .../com/festago/auth/domain/OAuth2ClientsTest.java | 5 ++--- .../CompositeAuthenticationTokenExtractorTest.java | 1 + .../AdminAuthenticationClaimsExtractorTest.java | 4 ++-- .../infrastructure/{ => jwt}/JwtTokenParserTest.java | 2 +- .../MemberAuthenticationClaimsExtractorTest.java | 4 ++-- .../{ => jwt}/TokenProviderTemplateTest.java | 2 +- .../{ => oauth2}/KakaoOAuth2TokenClientTest.java | 3 +-- .../{ => openid}/CachedOpenIdKeyProviderTest.java | 3 +-- .../{ => openid}/KakaoOpenIdClientTest.java | 8 +++----- .../{ => openid}/KakaoOpenIdJwksClientTest.java | 3 +-- .../CompositeHttpRequestTokenExtractorTest.java | 2 +- .../CookieHttpRequestTokenExtractorTest.java | 2 +- .../HeaderHttpRequestTokenExtractorTest.java | 2 +- .../presentation/v1/MemberAuthV1ControllerTest.java | 2 +- .../java/com/festago/member/domain/MemberTest.java | 1 - .../member/repository/MemoryMemberRepository.java | 2 +- .../support/MockAuthTestExecutionListener.java | 4 ++-- .../support/MockAuthenticationTokenExtractor.java | 2 +- .../test/java/com/festago/support/TestAuthConfig.java | 2 +- .../com/festago/support/fixture/MemberFixture.java | 2 +- 66 files changed, 102 insertions(+), 109 deletions(-) delete mode 100644 backend/src/main/java/com/festago/auth/application/OAuth2Client.java rename backend/src/main/java/com/festago/auth/{ => domain}/AuthenticateContext.java (92%) create mode 100644 backend/src/main/java/com/festago/auth/domain/OAuth2Client.java rename backend/src/main/java/com/festago/auth/{application => domain}/OAuth2Clients.java (95%) rename backend/src/main/java/com/festago/auth/dto/v1/{LoginResult.java => MemberLoginResult.java} (87%) rename backend/src/main/java/com/festago/auth/infrastructure/{ => jwt}/AdminAuthenticationClaimsExtractor.java (80%) rename backend/src/main/java/com/festago/auth/infrastructure/{ => jwt}/AuthenticationClaimsExtractor.java (92%) rename backend/src/main/java/com/festago/auth/infrastructure/{ => jwt}/JwtTokenParser.java (97%) rename backend/src/main/java/com/festago/auth/infrastructure/{ => jwt}/MemberAuthenticationClaimsExtractor.java (80%) rename backend/src/main/java/com/festago/auth/infrastructure/{ => jwt}/TokenProviderTemplate.java (96%) rename backend/src/main/java/com/festago/auth/infrastructure/{ => web}/CompositeHttpRequestTokenExtractor.java (87%) rename backend/src/main/java/com/festago/auth/infrastructure/{ => web}/CookieHttpRequestTokenExtractor.java (87%) rename backend/src/main/java/com/festago/auth/infrastructure/{ => web}/HeaderHttpRequestTokenExtractor.java (90%) rename backend/src/main/java/com/festago/auth/{application => infrastructure/web}/HttpRequestTokenExtractor.java (80%) rename backend/src/main/java/com/festago/{auth => member}/domain/SocialType.java (66%) rename backend/src/main/java/com/festago/{auth => member}/infrastructure/SocialTypeConverter.java (79%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => jwt}/AdminAuthenticationClaimsExtractorTest.java (96%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => jwt}/JwtTokenParserTest.java (98%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => jwt}/MemberAuthenticationClaimsExtractorTest.java (95%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => jwt}/TokenProviderTemplateTest.java (96%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => oauth2}/KakaoOAuth2TokenClientTest.java (97%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => openid}/CachedOpenIdKeyProviderTest.java (96%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => openid}/KakaoOpenIdClientTest.java (95%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => openid}/KakaoOpenIdJwksClientTest.java (97%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => web}/CompositeHttpRequestTokenExtractorTest.java (97%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => web}/CookieHttpRequestTokenExtractorTest.java (97%) rename backend/src/test/java/com/festago/auth/infrastructure/{ => web}/HeaderHttpRequestTokenExtractorTest.java (97%) diff --git a/backend/src/main/java/com/festago/auth/AdminAuthenticationArgumentResolver.java b/backend/src/main/java/com/festago/auth/AdminAuthenticationArgumentResolver.java index c62ede6a2..a82cc9f39 100644 --- a/backend/src/main/java/com/festago/auth/AdminAuthenticationArgumentResolver.java +++ b/backend/src/main/java/com/festago/auth/AdminAuthenticationArgumentResolver.java @@ -1,5 +1,6 @@ package com.festago.auth; +import com.festago.auth.domain.AuthenticateContext; import com.festago.auth.domain.authentication.AdminAuthentication; import com.festago.auth.domain.authentication.Authentication; import com.festago.common.exception.UnexpectedException; diff --git a/backend/src/main/java/com/festago/auth/AnnotationAuthorizationInterceptor.java b/backend/src/main/java/com/festago/auth/AnnotationAuthorizationInterceptor.java index 02eaefc0d..1589c368f 100644 --- a/backend/src/main/java/com/festago/auth/AnnotationAuthorizationInterceptor.java +++ b/backend/src/main/java/com/festago/auth/AnnotationAuthorizationInterceptor.java @@ -1,9 +1,10 @@ package com.festago.auth; import com.festago.auth.annotation.Authorization; -import com.festago.auth.application.HttpRequestTokenExtractor; +import com.festago.auth.domain.AuthenticateContext; import com.festago.auth.domain.AuthenticationTokenExtractor; import com.festago.auth.domain.authentication.Authentication; +import com.festago.auth.infrastructure.web.HttpRequestTokenExtractor; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.ForbiddenException; import com.festago.common.exception.UnauthorizedException; @@ -23,8 +24,7 @@ public class AnnotationAuthorizationInterceptor implements HandlerInterceptor { public AnnotationAuthorizationInterceptor( HttpRequestTokenExtractor httpRequestTokenExtractor, AuthenticationTokenExtractor authenticationTokenExtractor, - AuthenticateContext authenticateContext) - { + AuthenticateContext authenticateContext) { Assert.notNull(httpRequestTokenExtractor, "The httpRequestTokenExtractor must not be null"); Assert.notNull(authenticationTokenExtractor, "The authenticationTokenExtractor must not be null"); Assert.notNull(authenticateContext, "The authenticateContext must not be null"); diff --git a/backend/src/main/java/com/festago/auth/FixedAuthorizationInterceptor.java b/backend/src/main/java/com/festago/auth/FixedAuthorizationInterceptor.java index 5689679fb..8301f54f3 100644 --- a/backend/src/main/java/com/festago/auth/FixedAuthorizationInterceptor.java +++ b/backend/src/main/java/com/festago/auth/FixedAuthorizationInterceptor.java @@ -1,9 +1,10 @@ package com.festago.auth; -import com.festago.auth.application.HttpRequestTokenExtractor; +import com.festago.auth.domain.AuthenticateContext; import com.festago.auth.domain.AuthenticationTokenExtractor; import com.festago.auth.domain.Role; import com.festago.auth.domain.authentication.Authentication; +import com.festago.auth.infrastructure.web.HttpRequestTokenExtractor; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.ForbiddenException; import com.festago.common.exception.UnauthorizedException; diff --git a/backend/src/main/java/com/festago/auth/MemberAuthenticationArgumentResolver.java b/backend/src/main/java/com/festago/auth/MemberAuthenticationArgumentResolver.java index 12b219713..8b4a355d1 100644 --- a/backend/src/main/java/com/festago/auth/MemberAuthenticationArgumentResolver.java +++ b/backend/src/main/java/com/festago/auth/MemberAuthenticationArgumentResolver.java @@ -1,5 +1,6 @@ package com.festago.auth; +import com.festago.auth.domain.AuthenticateContext; import com.festago.auth.domain.authentication.Authentication; import com.festago.auth.domain.authentication.MemberAuthentication; import com.festago.common.exception.UnexpectedException; diff --git a/backend/src/main/java/com/festago/auth/RoleArgumentResolver.java b/backend/src/main/java/com/festago/auth/RoleArgumentResolver.java index 451288621..ae350ea4a 100644 --- a/backend/src/main/java/com/festago/auth/RoleArgumentResolver.java +++ b/backend/src/main/java/com/festago/auth/RoleArgumentResolver.java @@ -1,5 +1,6 @@ package com.festago.auth; +import com.festago.auth.domain.AuthenticateContext; import com.festago.auth.domain.Role; import com.festago.common.exception.UnexpectedException; import org.springframework.core.MethodParameter; diff --git a/backend/src/main/java/com/festago/auth/application/OAuth2Client.java b/backend/src/main/java/com/festago/auth/application/OAuth2Client.java deleted file mode 100644 index ad2d3fad4..000000000 --- a/backend/src/main/java/com/festago/auth/application/OAuth2Client.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.festago.auth.application; - -import com.festago.auth.domain.SocialType; -import com.festago.auth.domain.UserInfo; - -public interface OAuth2Client { - - UserInfo getUserInfo(String code); - - SocialType getSocialType(); -} diff --git a/backend/src/main/java/com/festago/auth/application/command/MemberAuthCommandService.java b/backend/src/main/java/com/festago/auth/application/command/MemberAuthCommandService.java index 80279b72e..b382add7b 100644 --- a/backend/src/main/java/com/festago/auth/application/command/MemberAuthCommandService.java +++ b/backend/src/main/java/com/festago/auth/application/command/MemberAuthCommandService.java @@ -4,7 +4,7 @@ import com.festago.auth.domain.UserInfo; import com.festago.auth.domain.UserInfoMemberMapper; import com.festago.auth.dto.event.MemberDeletedEvent; -import com.festago.auth.dto.v1.LoginResult; +import com.festago.auth.dto.v1.MemberLoginResult; import com.festago.auth.dto.v1.TokenRefreshResult; import com.festago.auth.repository.RefreshTokenRepository; import com.festago.common.exception.ErrorCode; @@ -32,11 +32,11 @@ public class MemberAuthCommandService { private final UserInfoMemberMapper userInfoMemberMapper; private final Clock clock; - public LoginResult login(UserInfo userInfo) { + public MemberLoginResult login(UserInfo userInfo) { Member member = memberRepository.findBySocialIdAndSocialType(userInfo.socialId(), userInfo.socialType()) .orElseGet(() -> signUp(userInfo)); RefreshToken refreshToken = saveRefreshToken(member.getId()); - return new LoginResult( + return new MemberLoginResult( member.getId(), member.getNickname(), member.getProfileImage(), diff --git a/backend/src/main/java/com/festago/auth/application/command/MemberAuthFacadeService.java b/backend/src/main/java/com/festago/auth/application/command/MemberAuthFacadeService.java index f028d3b99..9bc4514af 100644 --- a/backend/src/main/java/com/festago/auth/application/command/MemberAuthFacadeService.java +++ b/backend/src/main/java/com/festago/auth/application/command/MemberAuthFacadeService.java @@ -1,18 +1,18 @@ package com.festago.auth.application.command; -import com.festago.auth.application.OAuth2Client; -import com.festago.auth.application.OAuth2Clients; +import com.festago.auth.domain.OAuth2Client; +import com.festago.auth.domain.OAuth2Clients; import com.festago.auth.domain.OpenIdClient; import com.festago.auth.domain.OpenIdClients; -import com.festago.auth.domain.SocialType; import com.festago.auth.domain.UserInfo; import com.festago.auth.domain.authentication.MemberAuthentication; -import com.festago.auth.dto.v1.LoginResult; import com.festago.auth.dto.v1.LoginV1Response; +import com.festago.auth.dto.v1.MemberLoginResult; import com.festago.auth.dto.v1.TokenRefreshResult; import com.festago.auth.dto.v1.TokenRefreshV1Response; import com.festago.auth.dto.v1.TokenResponse; import com.festago.auth.infrastructure.MemberAuthenticationTokenProvider; +import com.festago.member.domain.SocialType; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -33,7 +33,7 @@ public LoginV1Response oAuth2Login(SocialType socialType, String code) { } private LoginV1Response login(UserInfo userInfo) { - LoginResult loginResult = memberAuthCommandService.login(userInfo); + MemberLoginResult loginResult = memberAuthCommandService.login(userInfo); TokenResponse accessToken = authTokenProvider.provide(new MemberAuthentication(loginResult.memberId())); return new LoginV1Response( diff --git a/backend/src/main/java/com/festago/auth/config/AuthConfig.java b/backend/src/main/java/com/festago/auth/config/AuthConfig.java index d7252d980..27a010c15 100644 --- a/backend/src/main/java/com/festago/auth/config/AuthConfig.java +++ b/backend/src/main/java/com/festago/auth/config/AuthConfig.java @@ -1,7 +1,7 @@ package com.festago.auth.config; -import com.festago.auth.application.OAuth2Client; -import com.festago.auth.application.OAuth2Clients; +import com.festago.auth.domain.OAuth2Client; +import com.festago.auth.domain.OAuth2Clients; import com.festago.auth.domain.OpenIdClient; import com.festago.auth.domain.OpenIdClients; import java.util.List; diff --git a/backend/src/main/java/com/festago/auth/config/LoginConfig.java b/backend/src/main/java/com/festago/auth/config/LoginConfig.java index 25729873a..a2c0a22e5 100644 --- a/backend/src/main/java/com/festago/auth/config/LoginConfig.java +++ b/backend/src/main/java/com/festago/auth/config/LoginConfig.java @@ -2,16 +2,16 @@ import com.festago.auth.AdminAuthenticationArgumentResolver; import com.festago.auth.AnnotationAuthorizationInterceptor; -import com.festago.auth.AuthenticateContext; import com.festago.auth.FixedAuthorizationInterceptor; import com.festago.auth.MemberAuthenticationArgumentResolver; import com.festago.auth.RoleArgumentResolver; import com.festago.auth.annotation.Authorization; +import com.festago.auth.domain.AuthenticateContext; import com.festago.auth.domain.AuthenticationTokenExtractor; import com.festago.auth.domain.Role; -import com.festago.auth.infrastructure.CompositeHttpRequestTokenExtractor; -import com.festago.auth.infrastructure.CookieHttpRequestTokenExtractor; -import com.festago.auth.infrastructure.HeaderHttpRequestTokenExtractor; +import com.festago.auth.infrastructure.web.CompositeHttpRequestTokenExtractor; +import com.festago.auth.infrastructure.web.CookieHttpRequestTokenExtractor; +import com.festago.auth.infrastructure.web.HeaderHttpRequestTokenExtractor; import com.festago.common.interceptor.AnnotationDelegateInterceptor; import com.festago.common.interceptor.HttpMethodDelegateInterceptor; import java.util.List; diff --git a/backend/src/main/java/com/festago/auth/AuthenticateContext.java b/backend/src/main/java/com/festago/auth/domain/AuthenticateContext.java similarity index 92% rename from backend/src/main/java/com/festago/auth/AuthenticateContext.java rename to backend/src/main/java/com/festago/auth/domain/AuthenticateContext.java index ba36ddb17..192bea75e 100644 --- a/backend/src/main/java/com/festago/auth/AuthenticateContext.java +++ b/backend/src/main/java/com/festago/auth/domain/AuthenticateContext.java @@ -1,6 +1,5 @@ -package com.festago.auth; +package com.festago.auth.domain; -import com.festago.auth.domain.Role; import com.festago.auth.domain.authentication.AnonymousAuthentication; import com.festago.auth.domain.authentication.Authentication; import org.springframework.stereotype.Component; diff --git a/backend/src/main/java/com/festago/auth/domain/OAuth2Client.java b/backend/src/main/java/com/festago/auth/domain/OAuth2Client.java new file mode 100644 index 000000000..4f4904485 --- /dev/null +++ b/backend/src/main/java/com/festago/auth/domain/OAuth2Client.java @@ -0,0 +1,10 @@ +package com.festago.auth.domain; + +import com.festago.member.domain.SocialType; + +public interface OAuth2Client { + + UserInfo getUserInfo(String code); + + SocialType getSocialType(); +} diff --git a/backend/src/main/java/com/festago/auth/application/OAuth2Clients.java b/backend/src/main/java/com/festago/auth/domain/OAuth2Clients.java similarity index 95% rename from backend/src/main/java/com/festago/auth/application/OAuth2Clients.java rename to backend/src/main/java/com/festago/auth/domain/OAuth2Clients.java index 8b7144d0e..34f49fa77 100644 --- a/backend/src/main/java/com/festago/auth/application/OAuth2Clients.java +++ b/backend/src/main/java/com/festago/auth/domain/OAuth2Clients.java @@ -1,9 +1,9 @@ -package com.festago.auth.application; +package com.festago.auth.domain; -import com.festago.auth.domain.SocialType; import com.festago.common.exception.BadRequestException; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.UnexpectedException; +import com.festago.member.domain.SocialType; import java.util.EnumMap; import java.util.List; import java.util.Map; diff --git a/backend/src/main/java/com/festago/auth/domain/OpenIdClient.java b/backend/src/main/java/com/festago/auth/domain/OpenIdClient.java index e35c02d56..c2f915b4d 100644 --- a/backend/src/main/java/com/festago/auth/domain/OpenIdClient.java +++ b/backend/src/main/java/com/festago/auth/domain/OpenIdClient.java @@ -1,5 +1,7 @@ package com.festago.auth.domain; +import com.festago.member.domain.SocialType; + public interface OpenIdClient { UserInfo getUserInfo(String idToken); diff --git a/backend/src/main/java/com/festago/auth/domain/OpenIdClients.java b/backend/src/main/java/com/festago/auth/domain/OpenIdClients.java index 3d00f12e3..6813e8ba2 100644 --- a/backend/src/main/java/com/festago/auth/domain/OpenIdClients.java +++ b/backend/src/main/java/com/festago/auth/domain/OpenIdClients.java @@ -3,6 +3,7 @@ import com.festago.common.exception.BadRequestException; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.UnexpectedException; +import com.festago.member.domain.SocialType; import java.util.EnumMap; import java.util.List; import java.util.Map; diff --git a/backend/src/main/java/com/festago/auth/domain/UserInfo.java b/backend/src/main/java/com/festago/auth/domain/UserInfo.java index 232b81e4f..a5243be47 100644 --- a/backend/src/main/java/com/festago/auth/domain/UserInfo.java +++ b/backend/src/main/java/com/festago/auth/domain/UserInfo.java @@ -1,5 +1,6 @@ package com.festago.auth.domain; +import com.festago.member.domain.SocialType; import lombok.Builder; @Builder diff --git a/backend/src/main/java/com/festago/auth/dto/v1/LoginResult.java b/backend/src/main/java/com/festago/auth/dto/v1/MemberLoginResult.java similarity index 87% rename from backend/src/main/java/com/festago/auth/dto/v1/LoginResult.java rename to backend/src/main/java/com/festago/auth/dto/v1/MemberLoginResult.java index cd968edc4..859d91589 100644 --- a/backend/src/main/java/com/festago/auth/dto/v1/LoginResult.java +++ b/backend/src/main/java/com/festago/auth/dto/v1/MemberLoginResult.java @@ -3,7 +3,7 @@ import java.time.LocalDateTime; import java.util.UUID; -public record LoginResult( +public record MemberLoginResult( Long memberId, String nickname, String profileImageUrl, diff --git a/backend/src/main/java/com/festago/auth/dto/v1/OAuth2LoginV1Request.java b/backend/src/main/java/com/festago/auth/dto/v1/OAuth2LoginV1Request.java index 94e159250..ed0d05f5c 100644 --- a/backend/src/main/java/com/festago/auth/dto/v1/OAuth2LoginV1Request.java +++ b/backend/src/main/java/com/festago/auth/dto/v1/OAuth2LoginV1Request.java @@ -1,6 +1,6 @@ package com.festago.auth.dto.v1; -import com.festago.auth.domain.SocialType; +import com.festago.member.domain.SocialType; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/backend/src/main/java/com/festago/auth/dto/v1/OpenIdLoginV1Request.java b/backend/src/main/java/com/festago/auth/dto/v1/OpenIdLoginV1Request.java index ea8002621..6d49b02f2 100644 --- a/backend/src/main/java/com/festago/auth/dto/v1/OpenIdLoginV1Request.java +++ b/backend/src/main/java/com/festago/auth/dto/v1/OpenIdLoginV1Request.java @@ -1,6 +1,6 @@ package com.festago.auth.dto.v1; -import com.festago.auth.domain.SocialType; +import com.festago.member.domain.SocialType; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationTokenExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationTokenExtractor.java index f816f78ca..18f899224 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationTokenExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationTokenExtractor.java @@ -2,6 +2,8 @@ import com.festago.auth.domain.AuthenticationTokenExtractor; import com.festago.auth.domain.authentication.Authentication; +import com.festago.auth.infrastructure.jwt.AdminAuthenticationClaimsExtractor; +import com.festago.auth.infrastructure.jwt.JwtTokenParser; import io.jsonwebtoken.Claims; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationTokenProvider.java b/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationTokenProvider.java index fe572fb13..45802e8f4 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationTokenProvider.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationTokenProvider.java @@ -3,6 +3,7 @@ import com.festago.auth.domain.Role; import com.festago.auth.domain.authentication.AdminAuthentication; import com.festago.auth.dto.v1.TokenResponse; +import com.festago.auth.infrastructure.jwt.TokenProviderTemplate; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -10,7 +11,6 @@ @RequiredArgsConstructor public class AdminAuthenticationTokenProvider { - private static final String ADMIN_ID_KEY = "adminId"; private static final long EXPIRATION_MINUTES = 60L * 24L; private final TokenProviderTemplate tokenProviderTemplate; @@ -19,7 +19,6 @@ public TokenResponse provide(AdminAuthentication adminAuthentication) { return tokenProviderTemplate.provide(EXPIRATION_MINUTES, jwtBuilder -> jwtBuilder .subject(adminAuthentication.getId().toString()) - .claim(ADMIN_ID_KEY, adminAuthentication.getId()) .audience().add(Role.ADMIN.name()).and() ); } diff --git a/backend/src/main/java/com/festago/auth/infrastructure/CompositeAuthenticationTokenExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/CompositeAuthenticationTokenExtractor.java index 96b7f02c1..e20c51dd8 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/CompositeAuthenticationTokenExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/CompositeAuthenticationTokenExtractor.java @@ -4,6 +4,8 @@ import com.festago.auth.domain.Role; import com.festago.auth.domain.authentication.AnonymousAuthentication; import com.festago.auth.domain.authentication.Authentication; +import com.festago.auth.infrastructure.jwt.AuthenticationClaimsExtractor; +import com.festago.auth.infrastructure.jwt.JwtTokenParser; import io.jsonwebtoken.Claims; import java.util.List; import lombok.RequiredArgsConstructor; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationTokenExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationTokenExtractor.java index dc83680c1..ab77178f9 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationTokenExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationTokenExtractor.java @@ -2,6 +2,8 @@ import com.festago.auth.domain.AuthenticationTokenExtractor; import com.festago.auth.domain.authentication.Authentication; +import com.festago.auth.infrastructure.jwt.JwtTokenParser; +import com.festago.auth.infrastructure.jwt.MemberAuthenticationClaimsExtractor; import io.jsonwebtoken.Claims; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationTokenProvider.java b/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationTokenProvider.java index 830acc15e..e4eaab794 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationTokenProvider.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationTokenProvider.java @@ -3,6 +3,7 @@ import com.festago.auth.domain.Role; import com.festago.auth.domain.authentication.MemberAuthentication; import com.festago.auth.dto.v1.TokenResponse; +import com.festago.auth.infrastructure.jwt.TokenProviderTemplate; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -10,7 +11,6 @@ @RequiredArgsConstructor public class MemberAuthenticationTokenProvider { - private static final String MEMBER_ID_KEY = "memberId"; private static final long EXPIRATION_MINUTES = 60L * 6L; private final TokenProviderTemplate tokenProviderTemplate; @@ -19,7 +19,6 @@ public TokenResponse provide(MemberAuthentication memberAuthentication) { return tokenProviderTemplate.provide(EXPIRATION_MINUTES, jwtBuilder -> jwtBuilder .subject(memberAuthentication.getId().toString()) - .claim(MEMBER_ID_KEY, memberAuthentication.getId()) .audience().add(Role.MEMBER.name()).and() ); } diff --git a/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationClaimsExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/jwt/AdminAuthenticationClaimsExtractor.java similarity index 80% rename from backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationClaimsExtractor.java rename to backend/src/main/java/com/festago/auth/infrastructure/jwt/AdminAuthenticationClaimsExtractor.java index 7a246ae0c..1c1c7410c 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/AdminAuthenticationClaimsExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/jwt/AdminAuthenticationClaimsExtractor.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.jwt; import com.festago.auth.domain.Role; import com.festago.auth.domain.authentication.AdminAuthentication; @@ -10,14 +10,12 @@ @Component public class AdminAuthenticationClaimsExtractor implements AuthenticationClaimsExtractor { - private static final String ADMIN_ID_KEY = "adminId"; - @Override public Authentication extract(Claims claims) { if (!claims.getAudience().contains(Role.ADMIN.name())) { return AnonymousAuthentication.getInstance(); } - Long adminId = claims.get(ADMIN_ID_KEY, Long.class); + Long adminId = Long.parseLong(claims.getSubject()); return new AdminAuthentication(adminId); } } diff --git a/backend/src/main/java/com/festago/auth/infrastructure/AuthenticationClaimsExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/jwt/AuthenticationClaimsExtractor.java similarity index 92% rename from backend/src/main/java/com/festago/auth/infrastructure/AuthenticationClaimsExtractor.java rename to backend/src/main/java/com/festago/auth/infrastructure/jwt/AuthenticationClaimsExtractor.java index 7cceb81d0..8312eb9bf 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/AuthenticationClaimsExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/jwt/AuthenticationClaimsExtractor.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.jwt; import com.festago.auth.domain.authentication.Authentication; import io.jsonwebtoken.Claims; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/JwtTokenParser.java b/backend/src/main/java/com/festago/auth/infrastructure/jwt/JwtTokenParser.java similarity index 97% rename from backend/src/main/java/com/festago/auth/infrastructure/JwtTokenParser.java rename to backend/src/main/java/com/festago/auth/infrastructure/jwt/JwtTokenParser.java index f5751116a..36b557a5d 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/JwtTokenParser.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/jwt/JwtTokenParser.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.jwt; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.UnauthorizedException; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationClaimsExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/jwt/MemberAuthenticationClaimsExtractor.java similarity index 80% rename from backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationClaimsExtractor.java rename to backend/src/main/java/com/festago/auth/infrastructure/jwt/MemberAuthenticationClaimsExtractor.java index 1c2653ca3..ae18f4eb4 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/MemberAuthenticationClaimsExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/jwt/MemberAuthenticationClaimsExtractor.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.jwt; import com.festago.auth.domain.Role; import com.festago.auth.domain.authentication.AnonymousAuthentication; @@ -10,14 +10,12 @@ @Component public class MemberAuthenticationClaimsExtractor implements AuthenticationClaimsExtractor { - private static final String MEMBER_ID_KEY = "memberId"; - @Override public Authentication extract(Claims claims) { if (!claims.getAudience().contains(Role.MEMBER.name())) { return AnonymousAuthentication.getInstance(); } - Long memberId = claims.get(MEMBER_ID_KEY, Long.class); + Long memberId = Long.parseLong(claims.getSubject()); return new MemberAuthentication(memberId); } } diff --git a/backend/src/main/java/com/festago/auth/infrastructure/TokenProviderTemplate.java b/backend/src/main/java/com/festago/auth/infrastructure/jwt/TokenProviderTemplate.java similarity index 96% rename from backend/src/main/java/com/festago/auth/infrastructure/TokenProviderTemplate.java rename to backend/src/main/java/com/festago/auth/infrastructure/jwt/TokenProviderTemplate.java index a6824bdcc..a90892eb2 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/TokenProviderTemplate.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/jwt/TokenProviderTemplate.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.jwt; import com.festago.auth.dto.v1.TokenResponse; import io.jsonwebtoken.JwtBuilder; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/oauth2/FestagoOAuth2Client.java b/backend/src/main/java/com/festago/auth/infrastructure/oauth2/FestagoOAuth2Client.java index 8010da157..4ac127d71 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/oauth2/FestagoOAuth2Client.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/oauth2/FestagoOAuth2Client.java @@ -1,10 +1,10 @@ package com.festago.auth.infrastructure.oauth2; -import com.festago.auth.application.OAuth2Client; -import com.festago.auth.domain.SocialType; +import com.festago.auth.domain.OAuth2Client; import com.festago.auth.domain.UserInfo; import com.festago.common.exception.BadRequestException; import com.festago.common.exception.ErrorCode; +import com.festago.member.domain.SocialType; import java.util.HashMap; import java.util.Map; import org.springframework.context.annotation.Profile; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/oauth2/KakaoOAuth2Client.java b/backend/src/main/java/com/festago/auth/infrastructure/oauth2/KakaoOAuth2Client.java index 3421faf25..93f5b27b7 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/oauth2/KakaoOAuth2Client.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/oauth2/KakaoOAuth2Client.java @@ -1,9 +1,9 @@ package com.festago.auth.infrastructure.oauth2; -import com.festago.auth.application.OAuth2Client; -import com.festago.auth.domain.SocialType; +import com.festago.auth.domain.OAuth2Client; import com.festago.auth.domain.UserInfo; import com.festago.auth.infrastructure.openid.KakaoOpenIdClient; +import com.festago.member.domain.SocialType; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/openid/AppleOpenIdClient.java b/backend/src/main/java/com/festago/auth/infrastructure/openid/AppleOpenIdClient.java index a64433ab3..68d8fed12 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/openid/AppleOpenIdClient.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/openid/AppleOpenIdClient.java @@ -2,8 +2,8 @@ import com.festago.auth.domain.OpenIdClient; import com.festago.auth.domain.OpenIdNonceValidator; -import com.festago.auth.domain.SocialType; import com.festago.auth.domain.UserInfo; +import com.festago.member.domain.SocialType; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import java.time.Clock; @@ -19,7 +19,6 @@ public class AppleOpenIdClient implements OpenIdClient { private static final String ISSUER = "https://appleid.apple.com"; private final OpenIdNonceValidator openIdNonceValidator; private final OpenIdIdTokenParser idTokenParser; - private final String clientId; public AppleOpenIdClient( @Value("${festago.oauth2.apple.client-id}") String appleClientId, @@ -27,11 +26,10 @@ public AppleOpenIdClient( OpenIdNonceValidator openIdNonceValidator, Clock clock ) { - this.clientId = appleClientId; this.openIdNonceValidator = openIdNonceValidator; this.idTokenParser = new OpenIdIdTokenParser(Jwts.parser() .keyLocator(appleOpenIdPublicKeyLocator) - .requireAudience(clientId) + .requireAudience(appleClientId) .requireIssuer(ISSUER) .clock(() -> Date.from(clock.instant())) .build()); diff --git a/backend/src/main/java/com/festago/auth/infrastructure/openid/FestagoOpenIdClient.java b/backend/src/main/java/com/festago/auth/infrastructure/openid/FestagoOpenIdClient.java index 836bb11dd..56c70487e 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/openid/FestagoOpenIdClient.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/openid/FestagoOpenIdClient.java @@ -1,10 +1,10 @@ package com.festago.auth.infrastructure.openid; import com.festago.auth.domain.OpenIdClient; -import com.festago.auth.domain.SocialType; import com.festago.auth.domain.UserInfo; import com.festago.common.exception.BadRequestException; import com.festago.common.exception.ErrorCode; +import com.festago.member.domain.SocialType; import java.util.HashMap; import java.util.Map; import java.util.function.Supplier; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/openid/KakaoOpenIdClient.java b/backend/src/main/java/com/festago/auth/infrastructure/openid/KakaoOpenIdClient.java index dffcb064c..ce1676fa0 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/openid/KakaoOpenIdClient.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/openid/KakaoOpenIdClient.java @@ -2,10 +2,10 @@ import com.festago.auth.domain.OpenIdClient; import com.festago.auth.domain.OpenIdNonceValidator; -import com.festago.auth.domain.SocialType; import com.festago.auth.domain.UserInfo; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.UnauthorizedException; +import com.festago.member.domain.SocialType; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import java.time.Clock; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/CompositeHttpRequestTokenExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/web/CompositeHttpRequestTokenExtractor.java similarity index 87% rename from backend/src/main/java/com/festago/auth/infrastructure/CompositeHttpRequestTokenExtractor.java rename to backend/src/main/java/com/festago/auth/infrastructure/web/CompositeHttpRequestTokenExtractor.java index ebb806424..5a010923a 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/CompositeHttpRequestTokenExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/web/CompositeHttpRequestTokenExtractor.java @@ -1,6 +1,5 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.web; -import com.festago.auth.application.HttpRequestTokenExtractor; import jakarta.servlet.http.HttpServletRequest; import java.util.List; import java.util.Optional; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/CookieHttpRequestTokenExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/web/CookieHttpRequestTokenExtractor.java similarity index 87% rename from backend/src/main/java/com/festago/auth/infrastructure/CookieHttpRequestTokenExtractor.java rename to backend/src/main/java/com/festago/auth/infrastructure/web/CookieHttpRequestTokenExtractor.java index b2504125c..2ebebb37a 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/CookieHttpRequestTokenExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/web/CookieHttpRequestTokenExtractor.java @@ -1,6 +1,5 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.web; -import com.festago.auth.application.HttpRequestTokenExtractor; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; import java.util.Objects; diff --git a/backend/src/main/java/com/festago/auth/infrastructure/HeaderHttpRequestTokenExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/web/HeaderHttpRequestTokenExtractor.java similarity index 90% rename from backend/src/main/java/com/festago/auth/infrastructure/HeaderHttpRequestTokenExtractor.java rename to backend/src/main/java/com/festago/auth/infrastructure/web/HeaderHttpRequestTokenExtractor.java index 74668dd22..49915c91a 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/HeaderHttpRequestTokenExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/web/HeaderHttpRequestTokenExtractor.java @@ -1,6 +1,5 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.web; -import com.festago.auth.application.HttpRequestTokenExtractor; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.UnauthorizedException; import jakarta.servlet.http.HttpServletRequest; diff --git a/backend/src/main/java/com/festago/auth/application/HttpRequestTokenExtractor.java b/backend/src/main/java/com/festago/auth/infrastructure/web/HttpRequestTokenExtractor.java similarity index 80% rename from backend/src/main/java/com/festago/auth/application/HttpRequestTokenExtractor.java rename to backend/src/main/java/com/festago/auth/infrastructure/web/HttpRequestTokenExtractor.java index 5bd5d43a9..76c54e9a1 100644 --- a/backend/src/main/java/com/festago/auth/application/HttpRequestTokenExtractor.java +++ b/backend/src/main/java/com/festago/auth/infrastructure/web/HttpRequestTokenExtractor.java @@ -1,4 +1,4 @@ -package com.festago.auth.application; +package com.festago.auth.infrastructure.web; import jakarta.servlet.http.HttpServletRequest; import java.util.Optional; diff --git a/backend/src/main/java/com/festago/auth/presentation/v1/MemberAuthV1Controller.java b/backend/src/main/java/com/festago/auth/presentation/v1/MemberAuthV1Controller.java index d389a3f98..619956cdf 100644 --- a/backend/src/main/java/com/festago/auth/presentation/v1/MemberAuthV1Controller.java +++ b/backend/src/main/java/com/festago/auth/presentation/v1/MemberAuthV1Controller.java @@ -2,7 +2,6 @@ import com.festago.auth.annotation.MemberAuth; import com.festago.auth.application.command.MemberAuthFacadeService; -import com.festago.auth.domain.SocialType; import com.festago.auth.domain.authentication.MemberAuthentication; import com.festago.auth.dto.v1.LoginV1Response; import com.festago.auth.dto.v1.LogoutV1Request; @@ -10,6 +9,7 @@ import com.festago.auth.dto.v1.OpenIdLoginV1Request; import com.festago.auth.dto.v1.RefreshTokenV1Request; import com.festago.auth.dto.v1.TokenRefreshV1Response; +import com.festago.member.domain.SocialType; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/backend/src/main/java/com/festago/common/handler/GlobalExceptionHandler.java b/backend/src/main/java/com/festago/common/handler/GlobalExceptionHandler.java index b26be3752..b58df8f95 100644 --- a/backend/src/main/java/com/festago/common/handler/GlobalExceptionHandler.java +++ b/backend/src/main/java/com/festago/common/handler/GlobalExceptionHandler.java @@ -1,6 +1,6 @@ package com.festago.common.handler; -import com.festago.auth.AuthenticateContext; +import com.festago.auth.domain.AuthenticateContext; import com.festago.common.exception.BadRequestException; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.FestaGoException; diff --git a/backend/src/main/java/com/festago/member/config/DefaultNicknamePolicyConfig.java b/backend/src/main/java/com/festago/member/config/DefaultNicknamePolicyConfig.java index f4565eb5e..a964d9825 100644 --- a/backend/src/main/java/com/festago/member/config/DefaultNicknamePolicyConfig.java +++ b/backend/src/main/java/com/festago/member/config/DefaultNicknamePolicyConfig.java @@ -12,7 +12,7 @@ public class DefaultNicknamePolicyConfig { @Bean public DefaultNicknamePolicy defaultNicknamePolicy() { List adjectives = List.of( - "츄러스를 먹는", "노래 부르는", "때창하는", "응원하는", + "츄러스를 먹는", "노래 부르는", "떼창하는", "응원하는", "응원봉을 든", "타코야끼를 먹는", "공연에 심취한", "신나는", "춤추는", "행복한", "즐거운", "신나는", "흥겨운" ); diff --git a/backend/src/main/java/com/festago/member/domain/Member.java b/backend/src/main/java/com/festago/member/domain/Member.java index a8c96cd05..fa8f77ba9 100644 --- a/backend/src/main/java/com/festago/member/domain/Member.java +++ b/backend/src/main/java/com/festago/member/domain/Member.java @@ -1,6 +1,5 @@ package com.festago.member.domain; -import com.festago.auth.domain.SocialType; import com.festago.common.domain.BaseTimeEntity; import com.festago.common.util.ImageUrlHelper; import com.festago.common.util.Validator; @@ -20,7 +19,6 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.Where; -import org.springframework.util.StringUtils; @Entity @SQLDelete(sql = "UPDATE member SET deleted_at = now(), nickname = '탈퇴한 회원', profile_image_url = '', social_id = null WHERE id=?") diff --git a/backend/src/main/java/com/festago/auth/domain/SocialType.java b/backend/src/main/java/com/festago/member/domain/SocialType.java similarity index 66% rename from backend/src/main/java/com/festago/auth/domain/SocialType.java rename to backend/src/main/java/com/festago/member/domain/SocialType.java index a9fd21cc3..5c6f8debf 100644 --- a/backend/src/main/java/com/festago/auth/domain/SocialType.java +++ b/backend/src/main/java/com/festago/member/domain/SocialType.java @@ -1,4 +1,4 @@ -package com.festago.auth.domain; +package com.festago.member.domain; public enum SocialType { KAKAO, diff --git a/backend/src/main/java/com/festago/auth/infrastructure/SocialTypeConverter.java b/backend/src/main/java/com/festago/member/infrastructure/SocialTypeConverter.java similarity index 79% rename from backend/src/main/java/com/festago/auth/infrastructure/SocialTypeConverter.java rename to backend/src/main/java/com/festago/member/infrastructure/SocialTypeConverter.java index 0a6cb2fe7..8061cc15a 100644 --- a/backend/src/main/java/com/festago/auth/infrastructure/SocialTypeConverter.java +++ b/backend/src/main/java/com/festago/member/infrastructure/SocialTypeConverter.java @@ -1,6 +1,6 @@ -package com.festago.auth.infrastructure; +package com.festago.member.infrastructure; -import com.festago.auth.domain.SocialType; +import com.festago.member.domain.SocialType; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Component; diff --git a/backend/src/main/java/com/festago/member/repository/MemberRepository.java b/backend/src/main/java/com/festago/member/repository/MemberRepository.java index 0004da02b..83b46bc84 100644 --- a/backend/src/main/java/com/festago/member/repository/MemberRepository.java +++ b/backend/src/main/java/com/festago/member/repository/MemberRepository.java @@ -1,9 +1,9 @@ package com.festago.member.repository; -import com.festago.auth.domain.SocialType; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.NotFoundException; import com.festago.member.domain.Member; +import com.festago.member.domain.SocialType; import java.util.Optional; import org.springframework.data.repository.Repository; diff --git a/backend/src/test/java/com/festago/auth/application/command/MemberAuthCommandServiceTest.java b/backend/src/test/java/com/festago/auth/application/command/MemberAuthCommandServiceTest.java index 8a6dd0c00..56c85ee92 100644 --- a/backend/src/test/java/com/festago/auth/application/command/MemberAuthCommandServiceTest.java +++ b/backend/src/test/java/com/festago/auth/application/command/MemberAuthCommandServiceTest.java @@ -7,7 +7,6 @@ import static org.mockito.BDDMockito.spy; import com.festago.auth.domain.RefreshToken; -import com.festago.auth.domain.SocialType; import com.festago.auth.domain.UserInfo; import com.festago.auth.domain.UserInfoMemberMapper; import com.festago.auth.repository.MemoryRefreshTokenRepository; @@ -17,6 +16,7 @@ import com.festago.common.exception.UnauthorizedException; import com.festago.member.domain.DefaultNicknamePolicy; import com.festago.member.domain.Member; +import com.festago.member.domain.SocialType; import com.festago.member.repository.MemberRepository; import com.festago.member.repository.MemoryMemberRepository; import com.festago.support.fixture.MemberFixture; diff --git a/backend/src/test/java/com/festago/auth/domain/OAuth2ClientsTest.java b/backend/src/test/java/com/festago/auth/domain/OAuth2ClientsTest.java index 7390080d5..470db6f76 100644 --- a/backend/src/test/java/com/festago/auth/domain/OAuth2ClientsTest.java +++ b/backend/src/test/java/com/festago/auth/domain/OAuth2ClientsTest.java @@ -5,13 +5,12 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; -import com.festago.auth.application.OAuth2Client; -import com.festago.auth.application.OAuth2Clients; -import com.festago.auth.application.OAuth2Clients.OAuth2ClientsBuilder; +import com.festago.auth.domain.OAuth2Clients.OAuth2ClientsBuilder; import com.festago.auth.infrastructure.oauth2.FestagoOAuth2Client; import com.festago.auth.infrastructure.oauth2.KakaoOAuth2Client; import com.festago.common.exception.BadRequestException; import com.festago.common.exception.UnexpectedException; +import com.festago.member.domain.SocialType; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.Test; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/CompositeAuthenticationTokenExtractorTest.java b/backend/src/test/java/com/festago/auth/infrastructure/CompositeAuthenticationTokenExtractorTest.java index a1c77dc00..aea4dce64 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/CompositeAuthenticationTokenExtractorTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/CompositeAuthenticationTokenExtractorTest.java @@ -7,6 +7,7 @@ import com.festago.auth.domain.authentication.AdminAuthentication; import com.festago.auth.domain.authentication.AnonymousAuthentication; import com.festago.auth.domain.authentication.Authentication; +import com.festago.auth.infrastructure.jwt.JwtTokenParser; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/AdminAuthenticationClaimsExtractorTest.java b/backend/src/test/java/com/festago/auth/infrastructure/jwt/AdminAuthenticationClaimsExtractorTest.java similarity index 96% rename from backend/src/test/java/com/festago/auth/infrastructure/AdminAuthenticationClaimsExtractorTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/jwt/AdminAuthenticationClaimsExtractorTest.java index b13765bd1..7b66606a8 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/AdminAuthenticationClaimsExtractorTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/jwt/AdminAuthenticationClaimsExtractorTest.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.jwt; import static org.assertj.core.api.Assertions.assertThat; @@ -39,7 +39,7 @@ class AdminAuthenticationClaimsExtractorTest { // given Claims claims = Jwts.claims() .audience().add(Role.ADMIN.name()).and() - .add("adminId", 1) + .subject("1") .build(); // when diff --git a/backend/src/test/java/com/festago/auth/infrastructure/JwtTokenParserTest.java b/backend/src/test/java/com/festago/auth/infrastructure/jwt/JwtTokenParserTest.java similarity index 98% rename from backend/src/test/java/com/festago/auth/infrastructure/JwtTokenParserTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/jwt/JwtTokenParserTest.java index 21bbafea8..a2eaa4dc1 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/JwtTokenParserTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/jwt/JwtTokenParserTest.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.jwt; import static com.festago.common.exception.ErrorCode.EXPIRED_AUTH_TOKEN; import static com.festago.common.exception.ErrorCode.INVALID_AUTH_TOKEN; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/MemberAuthenticationClaimsExtractorTest.java b/backend/src/test/java/com/festago/auth/infrastructure/jwt/MemberAuthenticationClaimsExtractorTest.java similarity index 95% rename from backend/src/test/java/com/festago/auth/infrastructure/MemberAuthenticationClaimsExtractorTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/jwt/MemberAuthenticationClaimsExtractorTest.java index 26e066f69..f1c1d81d1 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/MemberAuthenticationClaimsExtractorTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/jwt/MemberAuthenticationClaimsExtractorTest.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.jwt; import static org.assertj.core.api.Assertions.assertThat; @@ -39,7 +39,7 @@ class MemberAuthenticationClaimsExtractorTest { // given Claims claims = Jwts.claims() .audience().add(Role.MEMBER.name()).and() - .add("memberId", 1) + .subject("1") .build(); // when diff --git a/backend/src/test/java/com/festago/auth/infrastructure/TokenProviderTemplateTest.java b/backend/src/test/java/com/festago/auth/infrastructure/jwt/TokenProviderTemplateTest.java similarity index 96% rename from backend/src/test/java/com/festago/auth/infrastructure/TokenProviderTemplateTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/jwt/TokenProviderTemplateTest.java index 93d8dfff5..e2689422b 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/TokenProviderTemplateTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/jwt/TokenProviderTemplateTest.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.jwt; import static org.assertj.core.api.Assertions.assertThat; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/KakaoOAuth2TokenClientTest.java b/backend/src/test/java/com/festago/auth/infrastructure/oauth2/KakaoOAuth2TokenClientTest.java similarity index 97% rename from backend/src/test/java/com/festago/auth/infrastructure/KakaoOAuth2TokenClientTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/oauth2/KakaoOAuth2TokenClientTest.java index 05b1125b7..71bbc64ca 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/KakaoOAuth2TokenClientTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/oauth2/KakaoOAuth2TokenClientTest.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.oauth2; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -7,7 +7,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.festago.auth.dto.KakaoOAuth2TokenResponse; -import com.festago.auth.infrastructure.oauth2.KakaoOAuth2TokenClient; import com.festago.auth.infrastructure.oauth2.KakaoOAuth2AccessTokenErrorHandler.KakaoOAuth2ErrorResponse; import com.festago.common.exception.BadRequestException; import com.festago.common.exception.ErrorCode; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/CachedOpenIdKeyProviderTest.java b/backend/src/test/java/com/festago/auth/infrastructure/openid/CachedOpenIdKeyProviderTest.java similarity index 96% rename from backend/src/test/java/com/festago/auth/infrastructure/CachedOpenIdKeyProviderTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/openid/CachedOpenIdKeyProviderTest.java index c4b6cad68..470eaadf7 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/CachedOpenIdKeyProviderTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/openid/CachedOpenIdKeyProviderTest.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.openid; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; @@ -6,7 +6,6 @@ import static org.mockito.BDDMockito.times; import static org.mockito.BDDMockito.verify; -import com.festago.auth.infrastructure.openid.CachedOpenIdKeyProvider; import io.jsonwebtoken.security.JwkSet; import io.jsonwebtoken.security.Jwks; import java.security.Key; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/KakaoOpenIdClientTest.java b/backend/src/test/java/com/festago/auth/infrastructure/openid/KakaoOpenIdClientTest.java similarity index 95% rename from backend/src/test/java/com/festago/auth/infrastructure/KakaoOpenIdClientTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/openid/KakaoOpenIdClientTest.java index b19c4a98f..1295bc03c 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/KakaoOpenIdClientTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/openid/KakaoOpenIdClientTest.java @@ -1,14 +1,12 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.openid; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import com.festago.auth.infrastructure.openid.KakaoOpenIdClient; -import com.festago.auth.infrastructure.openid.KakaoOpenIdPublicKeyLocator; -import com.festago.auth.infrastructure.openid.NoopOpenIdNonceValidator; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.UnauthorizedException; import io.jsonwebtoken.Jwts; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/KakaoOpenIdJwksClientTest.java b/backend/src/test/java/com/festago/auth/infrastructure/openid/KakaoOpenIdJwksClientTest.java similarity index 97% rename from backend/src/test/java/com/festago/auth/infrastructure/KakaoOpenIdJwksClientTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/openid/KakaoOpenIdJwksClientTest.java index 58db2a900..0b16425a9 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/KakaoOpenIdJwksClientTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/openid/KakaoOpenIdJwksClientTest.java @@ -1,11 +1,10 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.openid; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import com.fasterxml.jackson.databind.ObjectMapper; -import com.festago.auth.infrastructure.openid.KakaoOpenIdJwksClient; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.InternalServerException; import io.jsonwebtoken.Identifiable; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/CompositeHttpRequestTokenExtractorTest.java b/backend/src/test/java/com/festago/auth/infrastructure/web/CompositeHttpRequestTokenExtractorTest.java similarity index 97% rename from backend/src/test/java/com/festago/auth/infrastructure/CompositeHttpRequestTokenExtractorTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/web/CompositeHttpRequestTokenExtractorTest.java index f85cf700c..4ce2f40af 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/CompositeHttpRequestTokenExtractorTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/web/CompositeHttpRequestTokenExtractorTest.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.web; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.mock; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/CookieHttpRequestTokenExtractorTest.java b/backend/src/test/java/com/festago/auth/infrastructure/web/CookieHttpRequestTokenExtractorTest.java similarity index 97% rename from backend/src/test/java/com/festago/auth/infrastructure/CookieHttpRequestTokenExtractorTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/web/CookieHttpRequestTokenExtractorTest.java index b4eaf33cd..0ffddebaf 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/CookieHttpRequestTokenExtractorTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/web/CookieHttpRequestTokenExtractorTest.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.web; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/backend/src/test/java/com/festago/auth/infrastructure/HeaderHttpRequestTokenExtractorTest.java b/backend/src/test/java/com/festago/auth/infrastructure/web/HeaderHttpRequestTokenExtractorTest.java similarity index 97% rename from backend/src/test/java/com/festago/auth/infrastructure/HeaderHttpRequestTokenExtractorTest.java rename to backend/src/test/java/com/festago/auth/infrastructure/web/HeaderHttpRequestTokenExtractorTest.java index 6fac009b2..a35f76bb9 100644 --- a/backend/src/test/java/com/festago/auth/infrastructure/HeaderHttpRequestTokenExtractorTest.java +++ b/backend/src/test/java/com/festago/auth/infrastructure/web/HeaderHttpRequestTokenExtractorTest.java @@ -1,4 +1,4 @@ -package com.festago.auth.infrastructure; +package com.festago.auth.infrastructure.web; import static com.festago.common.exception.ErrorCode.NOT_BEARER_TOKEN_TYPE; import static org.assertj.core.api.Assertions.assertThat; diff --git a/backend/src/test/java/com/festago/auth/presentation/v1/MemberAuthV1ControllerTest.java b/backend/src/test/java/com/festago/auth/presentation/v1/MemberAuthV1ControllerTest.java index 30a5d384c..c4145ffef 100644 --- a/backend/src/test/java/com/festago/auth/presentation/v1/MemberAuthV1ControllerTest.java +++ b/backend/src/test/java/com/festago/auth/presentation/v1/MemberAuthV1ControllerTest.java @@ -6,10 +6,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.fasterxml.jackson.databind.ObjectMapper; -import com.festago.auth.domain.SocialType; import com.festago.auth.dto.v1.OAuth2LoginV1Request; import com.festago.auth.dto.v1.OpenIdLoginV1Request; import com.festago.auth.dto.v1.RefreshTokenV1Request; +import com.festago.member.domain.SocialType; import com.festago.support.CustomWebMvcTest; import com.festago.support.WithMockAuth; import java.util.UUID; diff --git a/backend/src/test/java/com/festago/member/domain/MemberTest.java b/backend/src/test/java/com/festago/member/domain/MemberTest.java index 8c55e45a9..0f34295ab 100644 --- a/backend/src/test/java/com/festago/member/domain/MemberTest.java +++ b/backend/src/test/java/com/festago/member/domain/MemberTest.java @@ -3,7 +3,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import com.festago.auth.domain.SocialType; import com.festago.common.exception.ValidException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/backend/src/test/java/com/festago/member/repository/MemoryMemberRepository.java b/backend/src/test/java/com/festago/member/repository/MemoryMemberRepository.java index 390854743..19ac813cd 100644 --- a/backend/src/test/java/com/festago/member/repository/MemoryMemberRepository.java +++ b/backend/src/test/java/com/festago/member/repository/MemoryMemberRepository.java @@ -1,7 +1,7 @@ package com.festago.member.repository; -import com.festago.auth.domain.SocialType; import com.festago.member.domain.Member; +import com.festago.member.domain.SocialType; import com.festago.support.AbstractMemoryRepository; import java.util.Objects; import java.util.Optional; diff --git a/backend/src/test/java/com/festago/support/MockAuthTestExecutionListener.java b/backend/src/test/java/com/festago/support/MockAuthTestExecutionListener.java index 9fe5beb09..8bdb77881 100644 --- a/backend/src/test/java/com/festago/support/MockAuthTestExecutionListener.java +++ b/backend/src/test/java/com/festago/support/MockAuthTestExecutionListener.java @@ -1,10 +1,10 @@ package com.festago.support; -import com.festago.auth.AuthenticateContext; +import com.festago.auth.domain.AuthenticateContext; import com.festago.auth.domain.authentication.AdminAuthentication; import com.festago.auth.domain.authentication.AnonymousAuthentication; -import com.festago.auth.domain.authentication.MemberAuthentication; import com.festago.auth.domain.authentication.Authentication; +import com.festago.auth.domain.authentication.MemberAuthentication; import java.lang.reflect.Method; import org.springframework.context.ApplicationContext; import org.springframework.test.context.TestContext; diff --git a/backend/src/test/java/com/festago/support/MockAuthenticationTokenExtractor.java b/backend/src/test/java/com/festago/support/MockAuthenticationTokenExtractor.java index 4005fd9a9..48a3ac2f1 100644 --- a/backend/src/test/java/com/festago/support/MockAuthenticationTokenExtractor.java +++ b/backend/src/test/java/com/festago/support/MockAuthenticationTokenExtractor.java @@ -1,6 +1,6 @@ package com.festago.support; -import com.festago.auth.AuthenticateContext; +import com.festago.auth.domain.AuthenticateContext; import com.festago.auth.domain.AuthenticationTokenExtractor; import com.festago.auth.domain.authentication.Authentication; diff --git a/backend/src/test/java/com/festago/support/TestAuthConfig.java b/backend/src/test/java/com/festago/support/TestAuthConfig.java index 4c6a103cb..aa30f9c84 100644 --- a/backend/src/test/java/com/festago/support/TestAuthConfig.java +++ b/backend/src/test/java/com/festago/support/TestAuthConfig.java @@ -1,6 +1,6 @@ package com.festago.support; -import com.festago.auth.AuthenticateContext; +import com.festago.auth.domain.AuthenticateContext; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; diff --git a/backend/src/test/java/com/festago/support/fixture/MemberFixture.java b/backend/src/test/java/com/festago/support/fixture/MemberFixture.java index 4e1ae91b4..2c69b8cf6 100644 --- a/backend/src/test/java/com/festago/support/fixture/MemberFixture.java +++ b/backend/src/test/java/com/festago/support/fixture/MemberFixture.java @@ -1,7 +1,7 @@ package com.festago.support.fixture; -import com.festago.auth.domain.SocialType; import com.festago.member.domain.Member; +import com.festago.member.domain.SocialType; public class MemberFixture extends BaseFixture {