diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 93468f561..0e81809b9 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -33,7 +33,7 @@ jobs: - name: DB를 실행 run: | - docker-compose -f resources/test-develop-environment/docker-compose.yml up -d + docker-compose -f resources/local-develop-environment/docker-compose.yml up -d sleep 20 - name: Gradle 캐싱 diff --git a/BE/eeos/build.gradle b/BE/eeos/build.gradle index 545d67f5d..ca1e8f17c 100644 --- a/BE/eeos/build.gradle +++ b/BE/eeos/build.gradle @@ -74,6 +74,10 @@ dependencies { implementation 'org.flywaydb:flyway-core' implementation 'org.flywaydb:flyway-mysql' + // redis + implementation 'org.springframework.boot:spring-boot-starter-data-redis' + + // openfeign implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' diff --git a/BE/eeos/resources/local-develop-environment/docker-compose.yml b/BE/eeos/resources/local-develop-environment/docker-compose.yml index b3ca25a17..c107468ae 100644 --- a/BE/eeos/resources/local-develop-environment/docker-compose.yml +++ b/BE/eeos/resources/local-develop-environment/docker-compose.yml @@ -21,4 +21,10 @@ services: environment: - ADMINER_DEFAULT_SERVER=overflow-mysql8 - ADMINER_DESIGN=nette - - ADMINER_PLUGINS=tables-filter tinymce \ No newline at end of file + - ADMINER_PLUGINS=tables-filter tinymce + + overflow-redis: # Redis + container_name: eeos-redis + image: redis:latest + ports: + - "16379:6379" \ No newline at end of file diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/converter/OauthInfoEntityConverter.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/converter/OauthInfoEntityConverter.java deleted file mode 100644 index a3224b6d9..000000000 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/converter/OauthInfoEntityConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.blackcompany.eeos.auth.application.domain.converter; - -import com.blackcompany.eeos.auth.application.domain.OauthMemberModel; -import com.blackcompany.eeos.auth.persistence.OauthInfoEntity; -import com.blackcompany.eeos.common.support.converter.AbstractEntityConverter; -import org.springframework.stereotype.Component; - -@Component -public class OauthInfoEntityConverter - implements AbstractEntityConverter { - @Override - public OauthMemberModel from(final OauthInfoEntity oauthEntity) { - return OauthMemberModel.builder().oauthId(oauthEntity.getOauthId()).build(); - } - - @Override - public OauthInfoEntity toEntity(final OauthMemberModel oauthMemberModel) { - return OauthInfoEntity.builder().oauthId(oauthMemberModel.getOauthId()).build(); - } - - public OauthInfoEntity toEntity(final String oauthId, Long memberId) { - return OauthInfoEntity.builder().oauthId(oauthId).memberId(memberId).build(); - } -} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/converter/OauthMemberEntityConverter.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/converter/OauthMemberEntityConverter.java new file mode 100644 index 000000000..5b90a8648 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/converter/OauthMemberEntityConverter.java @@ -0,0 +1,24 @@ +package com.blackcompany.eeos.auth.application.domain.converter; + +import com.blackcompany.eeos.auth.application.domain.OauthMemberModel; +import com.blackcompany.eeos.auth.persistence.OAuthMemberEntity; +import com.blackcompany.eeos.common.support.converter.AbstractEntityConverter; +import org.springframework.stereotype.Component; + +@Component +public class OauthMemberEntityConverter + implements AbstractEntityConverter { + @Override + public OauthMemberModel from(final OAuthMemberEntity entity) { + return OauthMemberModel.builder().oauthId(entity.getOauthId()).build(); + } + + @Override + public OAuthMemberEntity toEntity(final OauthMemberModel model) { + return OAuthMemberEntity.builder().oauthId(model.getOauthId()).build(); + } + + public OAuthMemberEntity toEntity(final String oauthId, Long memberId) { + return OAuthMemberEntity.builder().oauthId(oauthId).memberId(memberId).build(); + } +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java index a11fcff04..bbc93a578 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java @@ -2,26 +2,23 @@ import com.blackcompany.eeos.auth.application.domain.OauthMemberModel; import com.blackcompany.eeos.auth.application.domain.TokenModel; +import com.blackcompany.eeos.auth.application.support.AuthenticationTokenGenerator; import com.blackcompany.eeos.auth.application.usecase.LoginUsecase; -import com.blackcompany.eeos.auth.persistence.OauthInfoEntity; +import com.blackcompany.eeos.auth.persistence.OAuthMemberEntity; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor -@Transactional public class AuthFacadeService implements LoginUsecase { private final OauthClientService oauthClientService; private final AuthService authService; - private final CreateTokenService createTokenService; + private final AuthenticationTokenGenerator authenticationTokenGenerator; - @Transactional(propagation = Propagation.REQUIRED) @Override public TokenModel login(String oauthServerType, String authCode, String uri) { OauthMemberModel model = oauthClientService.getOauthMember(oauthServerType, authCode, uri); - OauthInfoEntity entity = authService.login(model); - return createTokenService.execute(entity.getMemberId()); + OAuthMemberEntity entity = authService.authenticate(model); + return authenticationTokenGenerator.execute(entity.getMemberId()); } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthService.java index 87fd35a94..3cbc1f79f 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthService.java @@ -1,44 +1,42 @@ package com.blackcompany.eeos.auth.application.service; import com.blackcompany.eeos.auth.application.domain.OauthMemberModel; -import com.blackcompany.eeos.auth.application.domain.converter.OauthInfoEntityConverter; -import com.blackcompany.eeos.auth.persistence.OauthInfoEntity; -import com.blackcompany.eeos.auth.persistence.OauthInfoRepository; +import com.blackcompany.eeos.auth.application.domain.converter.OauthMemberEntityConverter; +import com.blackcompany.eeos.auth.persistence.OAuthMemberEntity; +import com.blackcompany.eeos.auth.persistence.OAuthMemberRepository; import com.blackcompany.eeos.member.application.model.converter.MemberEntityConverter; import com.blackcompany.eeos.member.persistence.MemberEntity; import com.blackcompany.eeos.member.persistence.MemberRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @Service -@Transactional(readOnly = true) @RequiredArgsConstructor +@Transactional(readOnly = true) public class AuthService { - - private final OauthInfoRepository oauthInfoRepository; private final MemberRepository memberRepository; + private final OAuthMemberRepository oAuthMemberRepository; private final MemberEntityConverter memberEntityConverter; - private final OauthInfoEntityConverter oauthInfoEntityConverter; + private final OauthMemberEntityConverter oauthMemberEntityConverter; - @Transactional(propagation = Propagation.REQUIRED) - public OauthInfoEntity login(final OauthMemberModel model) { - return oauthInfoRepository + @Transactional + public OAuthMemberEntity authenticate(final OauthMemberModel model) { + return oAuthMemberRepository .findByOauthId(model.getOauthId()) .orElseGet(() -> signUpMember(model)); } - private OauthInfoEntity signUpMember(final OauthMemberModel model) { + private OAuthMemberEntity signUpMember(final OauthMemberModel model) { MemberEntity entity = memberEntityConverter.toEntity(model.getName(), model.getOauthServerType()); MemberEntity savedMember = memberRepository.save(entity); - return createOauthInfoEntity(model.getOauthId(), savedMember.getId()); + return saveOauthInfoEntity(model.getOauthId(), savedMember.getId()); } - private OauthInfoEntity createOauthInfoEntity(final String oauthId, final Long memberId) { - OauthInfoEntity entity = oauthInfoEntityConverter.toEntity(oauthId, memberId); - return oauthInfoRepository.save(entity); + private OAuthMemberEntity saveOauthInfoEntity(final String oauthId, final Long memberId) { + OAuthMemberEntity entity = oauthMemberEntityConverter.toEntity(oauthId, memberId); + return oAuthMemberRepository.save(entity); } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/OauthClientService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/OauthClientService.java index be9654aff..993594a08 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/OauthClientService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/OauthClientService.java @@ -4,15 +4,12 @@ import com.blackcompany.eeos.auth.application.domain.client.OauthMemberClientComposite; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class OauthClientService { private final OauthMemberClientComposite oauthMemberClientComposite; - @Transactional(propagation = Propagation.REQUIRED) public OauthMemberModel getOauthMember(String oauthServerType, String authCode, String uri) { OauthMemberModel model = oauthMemberClientComposite.fetch(oauthServerType, authCode, uri); model.validateNameFormat(); diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/ReissueService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/ReissueService.java index a75bf1ed8..2fd99b886 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/ReissueService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/ReissueService.java @@ -3,45 +3,45 @@ import com.blackcompany.eeos.auth.application.domain.TokenModel; import com.blackcompany.eeos.auth.application.domain.token.TokenResolver; import com.blackcompany.eeos.auth.application.exception.InvalidTokenException; +import com.blackcompany.eeos.auth.application.support.AuthenticationTokenGenerator; import com.blackcompany.eeos.auth.application.usecase.ReissueUsecase; -import com.blackcompany.eeos.auth.persistence.AuthInfoEntity; -import com.blackcompany.eeos.auth.persistence.AuthInfoRepository; -import java.util.Optional; +import com.blackcompany.eeos.auth.persistence.MemberAuthenticationRepository; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor @Transactional(readOnly = true) -@Slf4j public class ReissueService implements ReissueUsecase { - private final CreateTokenService createTokenService; - private final AuthInfoRepository authInfoRepository; + private final AuthenticationTokenGenerator authenticationTokenGenerator; + private final MemberAuthenticationRepository memberAuthenticationRepository; private final TokenResolver tokenResolver; @Transactional @Override public TokenModel execute(final String token) { Long memberId = tokenResolver.getUserInfoByCookie(token); - validateToken(memberId, token); - return createTokenService.execute(memberId); + validateToken(token); + saveUsedToken(token, memberId); + + return authenticationTokenGenerator.execute(memberId); } - private void validateToken(final Long memberId, final String token) { - Optional validToken = - authInfoRepository.findByMemberIdAndToken(memberId, token); - if (validToken.isPresent()) { - validToken.ifPresent(authInfoRepository::delete); - return; + private void validateToken(final String token) { + boolean isExistToken = memberAuthenticationRepository.isExistToken(token); + + if (isExistToken) { + throw new InvalidTokenException(); } - deleteInvalidToken(token); } - private void deleteInvalidToken(final String token) { - authInfoRepository.findByToken(token).ifPresent(authInfoRepository::delete); - throw new InvalidTokenException(); + private void saveUsedToken(final String token, final Long memberId) { + memberAuthenticationRepository.save(token, memberId, getExpiredToken(token)); + } + + private Long getExpiredToken(final String token) { + return tokenResolver.getExpiredDateByHeader(token); } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/CreateTokenService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/support/AuthenticationTokenGenerator.java similarity index 52% rename from BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/CreateTokenService.java rename to BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/support/AuthenticationTokenGenerator.java index 8edddde04..7ed96d128 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/service/CreateTokenService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/support/AuthenticationTokenGenerator.java @@ -1,42 +1,27 @@ -package com.blackcompany.eeos.auth.application.service; +package com.blackcompany.eeos.auth.application.support; import com.blackcompany.eeos.auth.application.domain.TokenModel; import com.blackcompany.eeos.auth.application.domain.converter.TokenModelConverter; import com.blackcompany.eeos.auth.application.domain.token.TokenProvider; import com.blackcompany.eeos.auth.application.domain.token.TokenResolver; -import com.blackcompany.eeos.auth.persistence.AuthInfoEntity; -import com.blackcompany.eeos.auth.persistence.AuthInfoEntityConverter; -import com.blackcompany.eeos.auth.persistence.AuthInfoRepository; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; +import org.springframework.stereotype.Component; -@Service +@Component @RequiredArgsConstructor -@Transactional(readOnly = true) -public class CreateTokenService { +public class AuthenticationTokenGenerator { private final TokenProvider tokenProvider; private final TokenModelConverter tokenModelConverter; private final TokenResolver tokenResolver; - private final AuthInfoRepository authInfoRepository; - private final AuthInfoEntityConverter authInfoEntityConverter; - @Transactional public TokenModel execute(final Long memberId) { String accessToken = tokenProvider.createAccessToken(memberId); String refreshToken = tokenProvider.createRefreshToken(memberId); - saveToken(memberId, refreshToken); - return tokenModelConverter.from( accessToken, tokenResolver.getExpiredDateByHeader(accessToken), refreshToken, tokenResolver.getExpiredDateByCookie(refreshToken)); } - - private void saveToken(final Long memberId, final String token) { - AuthInfoEntity authInfoEntity = authInfoEntityConverter.from(memberId, token); - authInfoRepository.save(authInfoEntity); - } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoEntity.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoEntity.java deleted file mode 100644 index b519cf478..000000000 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoEntity.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.blackcompany.eeos.auth.persistence; - -import com.blackcompany.eeos.common.persistence.BaseEntity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Index; -import javax.persistence.Table; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.ToString; -import lombok.experimental.SuperBuilder; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -@ToString -@SuperBuilder(toBuilder = true) -@Entity -@Table( - name = AuthInfoEntity.ENTITY_PREFIX, - indexes = @Index(name = "idx_auth_info_member_id", columnList = "auth_info_member_id")) -public class AuthInfoEntity extends BaseEntity { - - public static final String ENTITY_PREFIX = "auth_info"; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = ENTITY_PREFIX + "_id", nullable = false) - private Long id; - - @Column(name = ENTITY_PREFIX + "_token", nullable = false) - private String token; - - @Column(name = ENTITY_PREFIX + "_member_id", nullable = false) - private Long memberId; -} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoEntityConverter.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoEntityConverter.java deleted file mode 100644 index 771325228..000000000 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoEntityConverter.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.blackcompany.eeos.auth.persistence; - -import org.springframework.stereotype.Component; - -@Component -public class AuthInfoEntityConverter { - - public AuthInfoEntity from(Long memberId, String refreshToken) { - return AuthInfoEntity.builder().memberId(memberId).token(refreshToken).build(); - } -} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoRepository.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoRepository.java deleted file mode 100644 index 7efb870d8..000000000 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.blackcompany.eeos.auth.persistence; - -import java.util.Optional; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -public interface AuthInfoRepository extends JpaRepository { - @Query("SELECT a FROM AuthInfoEntity a WHERE a.memberId=:memberId AND a.token =:token") - Optional findByMemberIdAndToken( - @Param("memberId") Long memberId, @Param("token") String token); - - @Query("SELECT a FROM AuthInfoEntity a WHERE a.token =:token") - Optional findByToken(@Param("token") String token); -} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/MemberAuthenticationEntity.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/MemberAuthenticationEntity.java new file mode 100644 index 000000000..29ceed9b3 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/MemberAuthenticationEntity.java @@ -0,0 +1,22 @@ +package com.blackcompany.eeos.auth.persistence; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.springframework.data.annotation.Id; +import org.springframework.data.redis.core.RedisHash; +import org.springframework.data.redis.core.TimeToLive; + +@RedisHash("MemberAuthentication") +@Getter +@Setter +@ToString +@AllArgsConstructor +@NoArgsConstructor +public class MemberAuthenticationEntity { + @Id private String token; + private Long memberId; + @TimeToLive private Long expiration; +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/MemberAuthenticationRepository.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/MemberAuthenticationRepository.java new file mode 100644 index 000000000..e3b05abdf --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/MemberAuthenticationRepository.java @@ -0,0 +1,21 @@ +package com.blackcompany.eeos.auth.persistence; + +import java.util.concurrent.TimeUnit; +import lombok.RequiredArgsConstructor; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Repository; + +@Repository +@RequiredArgsConstructor +public class MemberAuthenticationRepository { + + private final RedisTemplate redisTemplate; + + public void save(String key, Long value, Long expiredTime) { + redisTemplate.opsForValue().set(key, value, expiredTime, TimeUnit.MILLISECONDS); + } + + public boolean isExistToken(String key) { + return redisTemplate.hasKey(key); + } +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoEntity.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OAuthMemberEntity.java similarity index 85% rename from BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoEntity.java rename to BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OAuthMemberEntity.java index 0cc4ea385..ce188b9e1 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoEntity.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OAuthMemberEntity.java @@ -20,9 +20,9 @@ @ToString @SuperBuilder(toBuilder = true) @Entity -@Table(name = OauthInfoEntity.ENTITY_PREFIX) -public class OauthInfoEntity extends BaseEntity { - public static final String ENTITY_PREFIX = "oauth_info"; +@Table(name = OAuthMemberEntity.ENTITY_PREFIX) +public class OAuthMemberEntity extends BaseEntity { + public static final String ENTITY_PREFIX = "oauth_member"; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoRepository.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OAuthMemberRepository.java similarity index 51% rename from BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoRepository.java rename to BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OAuthMemberRepository.java index 33b8d0f66..a24d3d8df 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoRepository.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OAuthMemberRepository.java @@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -public interface OauthInfoRepository extends JpaRepository { - @Query("SELECT o FROM OauthInfoEntity o WHERE o.oauthId=:oauthId") - Optional findByOauthId(@Param("oauthId") String oauthId); +public interface OAuthMemberRepository extends JpaRepository { + @Query("SELECT o FROM OAuthMemberEntity o WHERE o.oauthId=:oauthId") + Optional findByOauthId(@Param("oauthId") String oauthId); } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/controller/AuthController.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/controller/AuthController.java index f49b8e5fb..b0efde529 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/controller/AuthController.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/controller/AuthController.java @@ -5,16 +5,17 @@ import com.blackcompany.eeos.auth.application.dto.response.TokenResponse; import com.blackcompany.eeos.auth.application.usecase.LoginUsecase; import com.blackcompany.eeos.auth.application.usecase.ReissueUsecase; +import com.blackcompany.eeos.auth.presentation.support.AuthConstants; import com.blackcompany.eeos.auth.presentation.support.TokenExtractor; import com.blackcompany.eeos.common.presentation.respnose.ApiResponse; import com.blackcompany.eeos.common.presentation.respnose.ApiResponseBody.SuccessBody; import com.blackcompany.eeos.common.presentation.respnose.ApiResponseGenerator; import com.blackcompany.eeos.common.presentation.respnose.MessageCode; -import com.blackcompany.eeos.common.utils.TimeUtil; +import com.blackcompany.eeos.common.presentation.support.CookieManager; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseCookie; import org.springframework.web.bind.annotation.PathVariable; @@ -29,26 +30,20 @@ public class AuthController { private final LoginUsecase loginUsecase; private final ReissueUsecase reissueUsecase; private final TokenExtractor tokenExtractor; + private final CookieManager cookieManager; private final TokenResponseConverter tokenResponseConverter; - private final String cookieKey; - private final String domain; - private final long validTime; public AuthController( LoginUsecase loginUsecase, ReissueUsecase reissueUsecase, @Qualifier("cookie") TokenExtractor tokenExtractor, TokenResponseConverter tokenResponseConverter, - @Value("${api.cookie-key}") String cookieKey, - @Value("${api.domain}") String domain, - @Value("${security.jwt.refresh.validTime}") long validTime) { + CookieManager cookieManager) { this.loginUsecase = loginUsecase; this.reissueUsecase = reissueUsecase; this.tokenExtractor = tokenExtractor; this.tokenResponseConverter = tokenResponseConverter; - this.cookieKey = cookieKey; - this.domain = domain; - this.validTime = validTime; + this.cookieManager = cookieManager; } @PostMapping("/login/{oauthServerType}") @@ -73,25 +68,14 @@ ApiResponse> reissue( return ApiResponseGenerator.success(response, HttpStatus.CREATED, MessageCode.CREATE); } - private TokenResponse toResponse(TokenModel tokenModel, HttpServletResponse httpResponse) { + private TokenResponse toResponse(TokenModel tokenModel, HttpServletResponse httpServletResponse) { TokenResponse response = tokenResponseConverter.from(tokenModel.getAccessToken(), tokenModel.getAccessExpiredTime()); - setCookie(httpResponse, tokenModel); - return response; - } - - private void setCookie(HttpServletResponse response, TokenModel tokenModel) { ResponseCookie cookie = - ResponseCookie.from(cookieKey, tokenModel.getRefreshToken()) - .path("/") - .domain(domain) - .httpOnly(true) - .secure(true) - .sameSite("None") - .maxAge(TimeUtil.convertSecondsFromMillis(validTime)) - .build(); + cookieManager.createCookie(AuthConstants.TOKEN_KEY, tokenModel.getRefreshToken()); + httpServletResponse.addHeader(HttpHeaders.SET_COOKIE, cookie.toString()); - response.addHeader("Set-Cookie", cookie.toString()); + return response; } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/AuthConstants.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/AuthConstants.java new file mode 100644 index 000000000..977f954c5 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/AuthConstants.java @@ -0,0 +1,5 @@ +package com.blackcompany.eeos.auth.presentation.support; + +public class AuthConstants { + public static final String TOKEN_KEY = "eeos_token"; +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/AuthCookieManager.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/AuthCookieManager.java new file mode 100644 index 000000000..7680d9102 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/AuthCookieManager.java @@ -0,0 +1,36 @@ +package com.blackcompany.eeos.auth.presentation.support; + +import com.blackcompany.eeos.common.presentation.support.CookieManager; +import com.blackcompany.eeos.common.utils.TimeUtil; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseCookie; +import org.springframework.stereotype.Component; + +@Component +public class AuthCookieManager implements CookieManager { + + private static final Boolean HTTP_ONLY = true; + private static final Boolean SECURE = true; + private static final String SAMESITE = "None"; + + @Value("${token.cookie.domain}") + private String domain; + + @Value("${token.cookie.path}") + private String path; + + @Value("${security.jwt.refresh.validTime}") + private Long validTime; + + @Override + public ResponseCookie createCookie(String key, String value) { + return ResponseCookie.from(key, value) + .path(path) + .domain(domain) + .httpOnly(HTTP_ONLY) + .secure(SECURE) + .sameSite(SAMESITE) + .maxAge(TimeUtil.convertSecondsFromMillis(validTime)) + .build(); + } +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/CookieTokenExtractor.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/CookieTokenExtractor.java index cd7baabd1..25d86d504 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/CookieTokenExtractor.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/presentation/support/CookieTokenExtractor.java @@ -8,14 +8,13 @@ @Component("cookie") public class CookieTokenExtractor implements TokenExtractor { - private static final String cookieKey = "eeos_token"; @Override public String extract(HttpServletRequest request) { Cookie[] cookies = getCookies(request); for (Cookie cookie : cookies) { - if (Objects.equals(cookieKey, cookie.getName())) { + if (Objects.equals(AuthConstants.TOKEN_KEY, cookie.getName())) { return getValue(cookie.getValue()); } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/common/presentation/support/CookieManager.java b/BE/eeos/src/main/java/com/blackcompany/eeos/common/presentation/support/CookieManager.java new file mode 100644 index 000000000..d52ac4ded --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/common/presentation/support/CookieManager.java @@ -0,0 +1,7 @@ +package com.blackcompany.eeos.common.presentation.support; + +import org.springframework.http.ResponseCookie; + +public interface CookieManager { + ResponseCookie createCookie(String key, String value); +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/config/RedisConfig.java b/BE/eeos/src/main/java/com/blackcompany/eeos/config/RedisConfig.java new file mode 100644 index 000000000..c887070e0 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/config/RedisConfig.java @@ -0,0 +1,30 @@ +package com.blackcompany.eeos.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; + +@Configuration +public class RedisConfig { + @Value("${spring.redis.host}") + private String host; + + @Value("${spring.redis.port}") + private int port; + + @Bean + public RedisConnectionFactory redisConnectionFactory() { + return new LettuceConnectionFactory(host, port); + } + + @Bean + public RedisTemplate redisTemplate() { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(redisConnectionFactory()); + + return redisTemplate; + } +} diff --git a/BE/eeos/src/main/resources/application-api.yml b/BE/eeos/src/main/resources/application-api.yml index a2c2dbbf3..c9498757e 100644 --- a/BE/eeos/src/main/resources/application-api.yml +++ b/BE/eeos/src/main/resources/application-api.yml @@ -7,6 +7,7 @@ cors: allow-origin: urls: ${CORS_URL} -api: - domain: ${API_DOMAIN} - cookie-key: ${COOKIE_KEY} \ No newline at end of file +token: + cookie: + domain: ${COOKIE_TOKEN_DOMAIN} + path: ${COOKIE_TOKEN_PATH} \ No newline at end of file diff --git a/BE/eeos/src/main/resources/application-local-redis.yml b/BE/eeos/src/main/resources/application-local-redis.yml new file mode 100644 index 000000000..cd99df1b1 --- /dev/null +++ b/BE/eeos/src/main/resources/application-local-redis.yml @@ -0,0 +1,7 @@ +spring: + config: + activate: + on-profile: local-redis + redis: + host: localhost + port : 16379 \ No newline at end of file diff --git a/BE/eeos/src/main/resources/application-redis.yml b/BE/eeos/src/main/resources/application-redis.yml new file mode 100644 index 000000000..a65cbc47f --- /dev/null +++ b/BE/eeos/src/main/resources/application-redis.yml @@ -0,0 +1,7 @@ +spring: + config: + activate: + on-profile: redis + redis: + host: ${REDIS_HOST} + port : ${REDIS_PORT} \ No newline at end of file diff --git a/BE/eeos/src/main/resources/application.yml b/BE/eeos/src/main/resources/application.yml index 51eb056bd..7944468c3 100644 --- a/BE/eeos/src/main/resources/application.yml +++ b/BE/eeos/src/main/resources/application.yml @@ -7,6 +7,7 @@ spring: - oauth - token - actuator + - local-redis dev: - mysql - api @@ -14,6 +15,7 @@ spring: - token - log - actuator + - redis prod: - mysql - api @@ -21,4 +23,5 @@ spring: - token - log - actuator + - redis active: local \ No newline at end of file diff --git a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java index bcd61d0e7..bd66449b4 100644 --- a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java +++ b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java @@ -4,8 +4,9 @@ import static org.mockito.Mockito.when; import com.blackcompany.eeos.auth.application.domain.OauthMemberModel; +import com.blackcompany.eeos.auth.application.support.AuthenticationTokenGenerator; import com.blackcompany.eeos.auth.fixture.FakeOauthMember; -import com.blackcompany.eeos.auth.persistence.OauthInfoEntity; +import com.blackcompany.eeos.auth.persistence.OAuthMemberEntity; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -16,10 +17,9 @@ @ExtendWith(MockitoExtension.class) class AuthFacadeServiceTest { - @Mock CreateTokenService createTokenService; - - @Mock AuthService authService; @Mock OauthClientService oauthClientService; + @Mock AuthenticationTokenGenerator authenticationTokenGenerator; + @Mock AuthService authService; @InjectMocks AuthFacadeService authFacadeService; @@ -33,15 +33,15 @@ void response_token() { String uri = "uri"; OauthMemberModel oauthMemberModel = FakeOauthMember.oauthMemberModel(); - OauthInfoEntity oauthInfoEntity = FakeOauthMember.oauthInfoEntity(); + OAuthMemberEntity oAuthMemberEntity = FakeOauthMember.oauthInfoEntity(); when(oauthClientService.getOauthMember(type, authCode, uri)).thenReturn(oauthMemberModel); - when(authService.login(oauthMemberModel)).thenReturn(oauthInfoEntity); + when(authService.authenticate(oauthMemberModel)).thenReturn(oAuthMemberEntity); // when authFacadeService.login(type, authCode, uri); // then - Mockito.verify(createTokenService).execute(memberId); + Mockito.verify(authenticationTokenGenerator).execute(memberId); } } diff --git a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthServiceTest.java b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthServiceTest.java index 5d2cc322f..0c7598697 100644 --- a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthServiceTest.java +++ b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthServiceTest.java @@ -5,10 +5,10 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.blackcompany.eeos.auth.application.domain.converter.OauthInfoEntityConverter; +import com.blackcompany.eeos.auth.application.domain.converter.OauthMemberEntityConverter; import com.blackcompany.eeos.auth.fixture.FakeOauthMember; -import com.blackcompany.eeos.auth.persistence.OauthInfoEntity; -import com.blackcompany.eeos.auth.persistence.OauthInfoRepository; +import com.blackcompany.eeos.auth.persistence.OAuthMemberEntity; +import com.blackcompany.eeos.auth.persistence.OAuthMemberRepository; import com.blackcompany.eeos.member.application.model.ActiveStatus; import com.blackcompany.eeos.member.application.model.converter.MemberEntityConverter; import com.blackcompany.eeos.member.fixture.MemberFixture; @@ -25,40 +25,40 @@ @ExtendWith(MockitoExtension.class) class AuthServiceTest { - @Mock OauthInfoRepository oauthInfoRepository; - @InjectMocks AuthService authService; - @Mock MemberRepository memberRepository; - @Spy OauthInfoEntityConverter oauthInfoEntityConverter; + @Mock MemberRepository memberRepository; + @Mock OAuthMemberRepository oAuthMemberRepository; @Spy MemberEntityConverter memberEntityConverter; + @Spy OauthMemberEntityConverter oauthMemberEntityConverter; + @InjectMocks AuthService authService; @Test - @DisplayName("새로운 회원인 경우 oauth에서 가져온 회원 정보를 저장한다.") + @DisplayName("신규 회원인 경우 oauth에서 가져온 회원 정보를 저장한다.") void login_existing_user() { // given - when(oauthInfoRepository.findByOauthId(FakeOauthMember.oauthMemberModel().getOauthId())) + when(oAuthMemberRepository.findByOauthId(FakeOauthMember.oauthMemberModel().getOauthId())) .thenReturn(Optional.ofNullable(null)); when(memberRepository.save(Mockito.any())) .thenReturn(MemberFixture.멤버_엔티티(1L, ActiveStatus.AM)); // when - authService.login(FakeOauthMember.oauthMemberModel()); + authService.authenticate(FakeOauthMember.oauthMemberModel()); // then assertAll( () -> verify(memberRepository).save(Mockito.any()), - () -> verify(oauthInfoRepository).save(Mockito.any())); + () -> verify(oAuthMemberRepository).save(Mockito.any())); } @Test @DisplayName("기존 회원인 경우 존재하던 oauth 정보를 가져온다.") void login_new_user() { // given - when(oauthInfoRepository.findByOauthId(FakeOauthMember.oauthMemberModel().getOauthId())) + when(oAuthMemberRepository.findByOauthId(FakeOauthMember.oauthMemberModel().getOauthId())) .thenReturn(Optional.of(FakeOauthMember.oauthInfoEntity())); // when - OauthInfoEntity entity = authService.login(FakeOauthMember.oauthMemberModel()); + OAuthMemberEntity entity = authService.authenticate(FakeOauthMember.oauthMemberModel()); // then assertEquals(entity.getOauthId(), FakeOauthMember.oauthMemberModel().getOauthId()); diff --git a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/CreateTokenServiceTest.java b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/CreateTokenServiceTest.java deleted file mode 100644 index 880deb38e..000000000 --- a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/CreateTokenServiceTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.blackcompany.eeos.auth.application.service; - -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.blackcompany.eeos.auth.application.domain.converter.TokenModelConverter; -import com.blackcompany.eeos.auth.application.domain.token.TokenProvider; -import com.blackcompany.eeos.auth.application.domain.token.TokenResolver; -import com.blackcompany.eeos.auth.persistence.AuthInfoEntity; -import com.blackcompany.eeos.auth.persistence.AuthInfoEntityConverter; -import com.blackcompany.eeos.auth.persistence.AuthInfoRepository; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class CreateTokenServiceTest { - @InjectMocks CreateTokenService createTokenService; - @Mock TokenResolver tokenResolver; - @Spy TokenModelConverter tokeModelConverter; - - @Mock TokenProvider tokenProvider; - @Mock AuthInfoRepository authInfoRepository; - @Mock AuthInfoEntityConverter authInfoEntityConverter; - - @Test - @DisplayName("토큰 생성 요청이 들어오면 토큰을 생성한 후 토큰을 저장한다.") - void save_token_when_request_create_token() { - // given - Long userId = 1L; - String accessToken = "mocked_access_token"; - String refreshToken = "mocked_refresh_token"; - - AuthInfoEntity entity = - AuthInfoEntity.builder().id(1L).memberId(userId).token(refreshToken).build(); - - when(tokenProvider.createAccessToken(userId)).thenReturn(accessToken); - when(tokenProvider.createRefreshToken(userId)).thenReturn(refreshToken); - when(authInfoEntityConverter.from(userId, refreshToken)).thenReturn(entity); - - // when - createTokenService.execute(userId); - - // then - verify(authInfoRepository).save(entity); - } -} diff --git a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/ReissueServiceTest.java b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/ReissueServiceTest.java index 9e674152f..881afe4c5 100644 --- a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/ReissueServiceTest.java +++ b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/application/service/ReissueServiceTest.java @@ -6,10 +6,8 @@ import com.blackcompany.eeos.auth.application.domain.token.TokenResolver; import com.blackcompany.eeos.auth.application.exception.InvalidTokenException; -import com.blackcompany.eeos.auth.fixture.FakeAuthInfo; -import com.blackcompany.eeos.auth.persistence.AuthInfoEntity; -import com.blackcompany.eeos.auth.persistence.AuthInfoRepository; -import java.util.Optional; +import com.blackcompany.eeos.auth.application.support.AuthenticationTokenGenerator; +import com.blackcompany.eeos.auth.persistence.MemberAuthenticationRepository; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -20,51 +18,44 @@ @ExtendWith(MockitoExtension.class) class ReissueServiceTest { - @Mock CreateTokenService createTokenService; - @Mock AuthInfoRepository authInfoRepository; + @Mock AuthenticationTokenGenerator authenticationTokenGenerator; + @Mock MemberAuthenticationRepository memberAuthenticationRepository; @Mock TokenResolver tokenResolver; @InjectMocks ReissueService reissueService; @Test - @DisplayName("전달받은 토큰이 서버가 가지고 있는 유저의 토큰이 아닐 때 유효하지 않은 토큰을 제거하고 예외를 발생시킨다.") + @DisplayName("블랙리스트에 등록된 토큰이 아니라면 예외가 발생한다.") void exception_when_token_invalid() { // given String token = "token"; Long memberId = 1L; - AuthInfoEntity authInfoEntity = FakeAuthInfo.authInfoEntity(); - when(tokenResolver.getUserInfoByCookie(token)).thenReturn(memberId); - when(authInfoRepository.findByMemberIdAndToken(memberId, token)) - .thenReturn(Optional.ofNullable(null)); - when(authInfoRepository.findByToken(token)).thenReturn(Optional.ofNullable(authInfoEntity)); + when(memberAuthenticationRepository.isExistToken(token)).thenReturn(Boolean.TRUE); // when & then - assertAll( - () -> assertThrows(InvalidTokenException.class, () -> reissueService.execute(token)), - () -> verify(authInfoRepository).delete(authInfoEntity)); + assertThrows(InvalidTokenException.class, () -> reissueService.execute(token)); } @Test - @DisplayName("전달받은 토큰이 유효한 토큰이라면 해당 토큰 정보를 제거하고 새로운 토큰을 생성한다.") - void execute() { + @DisplayName("정상적인 토큰이라면 이전에 사용한 토큰은 블랙리스트로 등록하고 새로운 토큰을 생성한다.") + void token_valid() { // given String token = "token"; Long memberId = 1L; - - AuthInfoEntity authInfoEntity = FakeAuthInfo.authInfoEntity(); + Long validTime = 1L; when(tokenResolver.getUserInfoByCookie(token)).thenReturn(memberId); - when(authInfoRepository.findByMemberIdAndToken(memberId, token)) - .thenReturn(Optional.ofNullable(authInfoEntity)); + when(memberAuthenticationRepository.isExistToken(token)).thenReturn(Boolean.FALSE); + when(tokenResolver.getExpiredDateByHeader(token)).thenReturn(validTime); // when reissueService.execute(token); // then assertAll( - () -> verify(authInfoRepository).delete(authInfoEntity), - () -> verify(createTokenService).execute(memberId)); + () -> verify(memberAuthenticationRepository).save(token, memberId, validTime), + () -> verify(authenticationTokenGenerator).execute(memberId)); } } diff --git a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthInfo.java b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthInfo.java deleted file mode 100644 index b09460013..000000000 --- a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthInfo.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.blackcompany.eeos.auth.fixture; - -import com.blackcompany.eeos.auth.persistence.AuthInfoEntity; - -public class FakeAuthInfo { - public static AuthInfoEntity authInfoEntity() { - return AuthInfoEntity.builder().memberId(1L).token("token").build(); - } -} diff --git a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeOauthMember.java b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeOauthMember.java index c27741375..d889ba058 100644 --- a/BE/eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeOauthMember.java +++ b/BE/eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeOauthMember.java @@ -2,7 +2,7 @@ import com.blackcompany.eeos.auth.application.domain.OauthMemberModel; import com.blackcompany.eeos.auth.application.domain.OauthServerType; -import com.blackcompany.eeos.auth.persistence.OauthInfoEntity; +import com.blackcompany.eeos.auth.persistence.OAuthMemberEntity; public class FakeOauthMember { public static OauthMemberModel oauthMemberModel() { @@ -13,7 +13,7 @@ public static OauthMemberModel oauthMemberModel() { .build(); } - public static OauthInfoEntity oauthInfoEntity() { - return OauthInfoEntity.builder().oauthId("oauthId").memberId(1L).build(); + public static OAuthMemberEntity oauthInfoEntity() { + return OAuthMemberEntity.builder().oauthId("oauthId").memberId(1L).build(); } } diff --git a/BE/eeos/src/test/resources/application-test-api.yml b/BE/eeos/src/test/resources/application-test-api.yml index 7f27f1ead..883b2cfef 100644 --- a/BE/eeos/src/test/resources/application-test-api.yml +++ b/BE/eeos/src/test/resources/application-test-api.yml @@ -2,10 +2,12 @@ spring: config: activate: on-profile: test-api + cors: allow-origin: urls: test -api: - domain: domain - cookie-key: key \ No newline at end of file +token: + cookie: + domain: domain + path: key \ No newline at end of file diff --git a/BE/eeos/src/test/resources/application-test-mysql.yml b/BE/eeos/src/test/resources/application-test-mysql.yml deleted file mode 100644 index 358d01a22..000000000 --- a/BE/eeos/src/test/resources/application-test-mysql.yml +++ /dev/null @@ -1,21 +0,0 @@ -spring: - config: - activate: - on-profile: test-mysql - datasource: - url: jdbc:mysql://localhost:13309/eeos?useSSL=false&serverTimezone=Asia/Seoul&useLegacyDatetimeCode=false&allowPublicKeyRetrieval=true - username: root - password: root - driver-class-name: com.mysql.cj.jdbc.Driver - jpa: - hibernate: - ddl-auto: create - properties: - hibernate: - format_sql: true - flyway: - enabled: false - -logging: - level: - sql: debug \ No newline at end of file diff --git a/BE/eeos/src/test/resources/application.yml b/BE/eeos/src/test/resources/application.yml index 21c8f965f..3f1c48125 100644 --- a/BE/eeos/src/test/resources/application.yml +++ b/BE/eeos/src/test/resources/application.yml @@ -2,7 +2,8 @@ spring: profiles: group: test: - - test-mysql + - local-mysql + - local-redis - test-api - test-token - test-oauth