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) - - -
diff --git a/src/HMH-Server.iml b/src/HMH-Server.iml deleted file mode 100644 index e69de29b..00000000 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/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/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); - } - } -} 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 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