From ee49c71d360e0fb2bfe3754df309a2e966dd5f94 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 30 May 2024 20:07:44 +0900 Subject: [PATCH 1/5] =?UTF-8?q?modify=20-=20#123=20RedisManagerService=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmh/domain/user/controller/UserApi.java | 2 +- .../user/controller/UserController.java | 3 +-- .../hmh/domain/user/service/UserService.java | 9 -------- .../org/hmh/global/auth/jwt/TokenService.java | 3 --- .../auth/redis/RedisManagerService.java | 21 ------------------- 5 files changed, 2 insertions(+), 36 deletions(-) delete mode 100644 src/main/java/sopt/org/hmh/global/auth/redis/RedisManagerService.java diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java index 56617336..d4a29939 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserApi.java @@ -9,7 +9,7 @@ public interface UserApi { @Operation(summary = "로그아웃") - ResponseEntity> orderLogout(@UserId @Parameter(hidden = true) final Long userId); + ResponseEntity> orderLogout(); @Operation(summary = "유저 정보 불러오기") ResponseEntity> orderGetUserInfo(@UserId @Parameter(hidden = true) final Long userId); diff --git a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java index 853f88b7..86d14391 100644 --- a/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java +++ b/src/main/java/sopt/org/hmh/domain/user/controller/UserController.java @@ -22,8 +22,7 @@ public class UserController implements UserApi{ @PostMapping("/logout") @Override - public ResponseEntity> orderLogout(@UserId final Long userId) { - userService.logout(userId); + public ResponseEntity> orderLogout() { return ResponseEntity .status(UserSuccess.LOGOUT_SUCCESS.getHttpStatus()) .body(BaseResponse.success(UserSuccess.LOGOUT_SUCCESS, new EmptyJsonResponse())); diff --git a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java index a631adb7..fdca204f 100644 --- a/src/main/java/sopt/org/hmh/domain/user/service/UserService.java +++ b/src/main/java/sopt/org/hmh/domain/user/service/UserService.java @@ -12,8 +12,6 @@ import sopt.org.hmh.domain.auth.exception.AuthException; import sopt.org.hmh.domain.auth.repository.OnboardingInfoRepository; import sopt.org.hmh.domain.auth.repository.ProblemRepository; -import sopt.org.hmh.domain.challenge.domain.exception.ChallengeError; -import sopt.org.hmh.domain.challenge.domain.exception.ChallengeException; import sopt.org.hmh.domain.user.domain.OnboardingInfo; import sopt.org.hmh.domain.user.domain.OnboardingProblem; import sopt.org.hmh.domain.user.domain.User; @@ -22,7 +20,6 @@ import sopt.org.hmh.domain.user.domain.exception.UserException; import sopt.org.hmh.domain.user.dto.response.UserInfoResponse; import sopt.org.hmh.domain.user.repository.UserRepository; -import sopt.org.hmh.global.auth.redis.RedisManagerService; import sopt.org.hmh.global.auth.social.SocialPlatform; @Service @@ -30,7 +27,6 @@ @Transactional(readOnly = true) public class UserService { - private final RedisManagerService redisManagerService; private final UserRepository userRepository; private final OnboardingInfoRepository onboardingInfoRepository; private final ProblemRepository problemRepository; @@ -38,14 +34,9 @@ public class UserService { @Transactional public void withdraw(Long userId) { - redisManagerService.deleteRefreshToken(userId); this.findByIdOrThrowException(userId).softDelete(); } - public void logout(Long userId) { - redisManagerService.deleteRefreshToken(userId); - } - public UserInfoResponse getUserInfo(Long userId) { return UserInfoResponse.of(this.findByIdOrThrowException(userId)); } diff --git a/src/main/java/sopt/org/hmh/global/auth/jwt/TokenService.java b/src/main/java/sopt/org/hmh/global/auth/jwt/TokenService.java index 66292c1e..64e2f6b9 100644 --- a/src/main/java/sopt/org/hmh/global/auth/jwt/TokenService.java +++ b/src/main/java/sopt/org/hmh/global/auth/jwt/TokenService.java @@ -6,7 +6,6 @@ import sopt.org.hmh.domain.auth.dto.response.ReissueResponse; import sopt.org.hmh.global.auth.jwt.exception.JwtError; import sopt.org.hmh.global.auth.jwt.exception.JwtException; -import sopt.org.hmh.global.auth.redis.RedisManagerService; @Service @RequiredArgsConstructor @@ -14,14 +13,12 @@ public class TokenService { private final JwtProvider jwtProvider; private final JwtValidator jwtValidator; - private final RedisManagerService redisManagerService; @Transactional public ReissueResponse reissueToken(String refreshToken) { String parsedRefreshToken = parseTokenString(refreshToken); Long userId = jwtProvider.getSubject(parsedRefreshToken); jwtValidator.validateRefreshToken(parsedRefreshToken); - redisManagerService.deleteRefreshToken(userId); return ReissueResponse.of(jwtProvider.issueToken(userId)); } diff --git a/src/main/java/sopt/org/hmh/global/auth/redis/RedisManagerService.java b/src/main/java/sopt/org/hmh/global/auth/redis/RedisManagerService.java deleted file mode 100644 index 812a5681..00000000 --- a/src/main/java/sopt/org/hmh/global/auth/redis/RedisManagerService.java +++ /dev/null @@ -1,21 +0,0 @@ -package sopt.org.hmh.global.auth.redis; - -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import sopt.org.hmh.global.auth.jwt.exception.JwtError; -import sopt.org.hmh.global.auth.jwt.exception.JwtException; - -@Service -@RequiredArgsConstructor -public class RedisManagerService { - - private final TokenRepository tokenRepository; - - public void deleteRefreshToken(Long userId) { - if (tokenRepository.existsById(userId)) { - tokenRepository.deleteById(userId); - } else { - throw new JwtException(JwtError.INVALID_REFRESH_TOKEN); - } - } -} From 0976ed96d51d4c59e37b6b99125291cca12ebdf8 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 21:16:45 +0900 Subject: [PATCH 2/5] =?UTF-8?q?modify=20-=20#123=20redis=20repository=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/hmh/global/auth/jwt/JwtGenerator.java | 16 +----------- .../hmh/global/auth/redis/RefreshToken.java | 25 ------------------- .../global/auth/redis/TokenRepository.java | 6 ----- 3 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 src/main/java/sopt/org/hmh/global/auth/redis/RefreshToken.java delete mode 100644 src/main/java/sopt/org/hmh/global/auth/redis/TokenRepository.java diff --git a/src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java b/src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java index 185280db..5da40648 100644 --- a/src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java +++ b/src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java @@ -11,8 +11,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import sopt.org.hmh.global.auth.redis.RefreshToken; -import sopt.org.hmh.global.auth.redis.TokenRepository; @Component @RequiredArgsConstructor @@ -25,29 +23,17 @@ public class JwtGenerator { @Value("${jwt.refresh-token-expiration-time}") private Long REFRESH_TOKEN_EXPIRATION_TIME; - private final TokenRepository tokenRepository; - public String generateToken(Long userId, boolean isRefreshToken) { final Date now = generateNowDate(); final Date expiration = generateExpirationDate(isRefreshToken, now); - String token = Jwts.builder() + return Jwts.builder() .setHeaderParam(Header.TYPE, Header.JWT_TYPE) .setSubject(String.valueOf(userId)) .setIssuedAt(now) .setExpiration(expiration) .signWith(getSigningKey()) .compact(); - - if (isRefreshToken) { - tokenRepository.save( - RefreshToken.builder() - .userId(userId) - .token(token) - .expiration(REFRESH_TOKEN_EXPIRATION_TIME / 1000) - .build()); - } - return token; } public JwtParser getJwtParser() { diff --git a/src/main/java/sopt/org/hmh/global/auth/redis/RefreshToken.java b/src/main/java/sopt/org/hmh/global/auth/redis/RefreshToken.java deleted file mode 100644 index cfb6e848..00000000 --- a/src/main/java/sopt/org/hmh/global/auth/redis/RefreshToken.java +++ /dev/null @@ -1,25 +0,0 @@ -package sopt.org.hmh.global.auth.redis; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.data.annotation.Id; -import org.springframework.data.redis.core.RedisHash; -import org.springframework.data.redis.core.TimeToLive; - -@Getter -@RedisHash(value = "refresh") -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class RefreshToken { - - @Id - private Long userId; - - private String token; - - @TimeToLive - private Long expiration; -} \ No newline at end of file diff --git a/src/main/java/sopt/org/hmh/global/auth/redis/TokenRepository.java b/src/main/java/sopt/org/hmh/global/auth/redis/TokenRepository.java deleted file mode 100644 index e550e700..00000000 --- a/src/main/java/sopt/org/hmh/global/auth/redis/TokenRepository.java +++ /dev/null @@ -1,6 +0,0 @@ -package sopt.org.hmh.global.auth.redis; - -import org.springframework.data.repository.CrudRepository; - -public interface TokenRepository extends CrudRepository { -} \ No newline at end of file From b218e64f2578b693c8149740ef0ab88a181ceed6 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 21:19:02 +0900 Subject: [PATCH 3/5] =?UTF-8?q?modify=20-=20#123=20redis=20config=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/hmh/global/config/RedisConfig.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/main/java/sopt/org/hmh/global/config/RedisConfig.java diff --git a/src/main/java/sopt/org/hmh/global/config/RedisConfig.java b/src/main/java/sopt/org/hmh/global/config/RedisConfig.java deleted file mode 100644 index ff8e702e..00000000 --- a/src/main/java/sopt/org/hmh/global/config/RedisConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package sopt.org.hmh.global.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.RedisStandaloneConfiguration; -import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; -import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; - -@Configuration -@EnableRedisRepositories -public class RedisConfig { - - @Value("${spring.data.redis.host}") - private String host; - - @Value("${spring.data.redis.port}") - private int port; - - @Value("${spring.data.redis.password}") - private String password; - - @Bean - public RedisConnectionFactory redisConnectionFactory() { - RedisStandaloneConfiguration redisConfiguration = new RedisStandaloneConfiguration(); - redisConfiguration.setHostName(host); - redisConfiguration.setPort(port); - redisConfiguration.setPassword(password); - return new LettuceConnectionFactory(redisConfiguration); - } -} \ No newline at end of file From a349d3003494141f53d7542c3139517822a0d218 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 21:23:49 +0900 Subject: [PATCH 4/5] =?UTF-8?q?chore=20-=20#123=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/HMH-Server.iml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/HMH-Server.iml diff --git a/src/HMH-Server.iml b/src/HMH-Server.iml deleted file mode 100644 index e69de29b..00000000 From e097086aab20114b9dc19f4aee2846115714d983 Mon Sep 17 00:00:00 2001 From: kseysh Date: Fri, 31 May 2024 21:24:07 +0900 Subject: [PATCH 5/5] =?UTF-8?q?docs=20-=20#123=20readme=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/README.md b/README.md index 1a8eb0cc..352f5b01 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ - **Language** : Java (jdk-17) - **Web application Framework** : Spring boot (3.2.1), Spring Data JPA -- **DataBase** : MySql (8.1.0), Redis +- **DataBase** : MySql (8.1.0) - **Cloud/Infra** : Aws EC2, RDS, code deploy - **web server** : Tomcat, Nginx - **Collaborative Tool** : Github, Slack, Notion @@ -28,34 +28,4 @@ | image | image | | [jumining](https://github.com/jumining) | [kseysh](https://github.com/kseysh) | -
- -## ✅ Convention - - - -### 🚀Convention - -- [💻 협업 컨벤션](https://hmhteam.notion.site/6fa22000670d4cf783559f7808c01d1a?pvs=4)
- -### 🚀 Branch Strategy - -- [💻 브랜치 전략](https://hmhteam.notion.site/9d8065b238c543b890ceeb9912966dd0?pvs=4) - -
- -## 💾 ERD - -![image](https://github.com/Team-HMH/HMH-Server/assets/69035864/f4b95b3d-6507-4d33-be41-8a4847bc076f) - -
- -
- -## ⚙️ Architecture - -![architecture](https://github.com/Team-HMH/HMH-Server/assets/69035864/e0eefac1-d8be-4a08-a3de-6e9786557042) - - -