-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from studio-recoding/dev
[🚀feat] 21차 배포
- Loading branch information
Showing
31 changed files
with
316 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,20 +77,23 @@ jobs: | |
host: ${{ secrets.HOST_DEV }} | ||
username: ${{ secrets.USER_DEV }} | ||
key: ${{ secrets.KEY_DEV }} | ||
script: mkdir -p ./dev | ||
script: mkdir -p ./ness | ||
|
||
## 소스 코드 복사 붙여넣기 | ||
- name: copy source via ssh key | ||
uses: burnett01/[email protected] | ||
with: | ||
switches: -avzr --delete | ||
path: ./config | ||
remote_path: ./dev | ||
remote_path: ./ness | ||
remote_host: ${{ secrets.HOST_DEV }} | ||
remote_user: ${{ secrets.USER_DEV }} | ||
remote_key: ${{ secrets.KEY_DEV }} | ||
|
||
## EC2에 배포(CD) | ||
## 아래 두 개는 이미 되어 있는 상태 | ||
## docker network create ness_network | ||
## docker network connect ness_network redis-server | ||
- name: executing remote ssh commands using password | ||
uses: appleboy/ssh-action@master | ||
with: | ||
|
@@ -100,8 +103,9 @@ jobs: | |
script: | | ||
sh ./dev/config/scripts/deploy.sh | ||
sudo docker stop $(sudo docker ps -a -q) | ||
sudo docker rm $(sudo docker ps -a -q) | ||
sudo docker stop $(sudo docker ps -a --filter="name=backend-server" -q) | ||
sudo docker rm $(sudo docker ps -a --filter="name=backend-server" -q) | ||
sudo docker rmi $(sudo docker images -q) | ||
docker pull jeonhaeseung/ness-server-dev:dev | ||
docker run -d --name backend-server -p 80:8080 --restart unless-stopped jeonhaeseung/ness-server-dev:dev | ||
docker run -d --name backend-server -p 80:8080 --restart unless-stopped jeonhaeseung/ness-server-dev:dev | ||
docker network connect ness_network backend-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,20 +82,23 @@ jobs: | |
host: ${{ secrets.HOST_PROD }} | ||
username: ${{ secrets.USER_PROD }} | ||
key: ${{ secrets.KEY_PROD }} | ||
script: mkdir -p ./prod | ||
script: mkdir -p ./ness | ||
|
||
## 소스 코드 복사 붙여넣기 | ||
- name: copy source via ssh key | ||
uses: burnett01/[email protected] | ||
with: | ||
switches: -avzr --delete | ||
path: ./config | ||
remote_path: ./prod | ||
remote_path: ./ness | ||
remote_host: ${{ secrets.HOST_PROD }} | ||
remote_user: ${{ secrets.USER_PROD }} | ||
remote_key: ${{ secrets.KEY_PROD }} | ||
|
||
## EC2에 배포(CD) | ||
## 아래 두 개는 이미 되어 있는 상태 | ||
## docker network create ness_network | ||
## docker network connect ness_network redis-server | ||
- name: executing remote ssh commands using password | ||
uses: appleboy/ssh-action@master | ||
with: | ||
|
@@ -105,8 +108,9 @@ jobs: | |
script: | | ||
sh ./prod/config/scripts/deploy.sh | ||
sudo docker stop $(sudo docker ps -a -q) | ||
sudo docker rm $(sudo docker ps -a -q) | ||
sudo docker stop $(sudo docker ps -a --filter="name=backend-server" -q) | ||
sudo docker rm $(sudo docker ps -a --filter="name=backend-server" -q) | ||
sudo docker rmi $(sudo docker images -q) | ||
docker pull jeonhaeseung/ness-server-prod:main | ||
docker run -d --name backend-server -p 80:8080 --restart unless-stopped jeonhaeseung/ness-server-prod:main | ||
docker run -d --name backend-server -p 80:8080 --restart unless-stopped jeonhaeseung/ness-server-prod:main | ||
docker network connect ness_network backend-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/Ness/Backend/domain/auth/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package Ness.Backend.domain.auth; | ||
|
||
import Ness.Backend.domain.auth.dto.request.PostRefreshTokenDto; | ||
import Ness.Backend.domain.auth.dto.response.GetJwtTokenDto; | ||
import Ness.Backend.domain.member.entity.Member; | ||
import Ness.Backend.global.auth.AuthUser; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatusCode; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping(value = "/auth") | ||
public class AuthController { | ||
private final AuthService authService; | ||
|
||
@PostMapping("/logout") | ||
@Operation(summary = "로그아웃 요청", description = "로그아웃 요청 API 입니다.") | ||
public ResponseEntity<?> logout(@AuthUser Member member, @RequestBody PostRefreshTokenDto postRefreshTokenDto) { | ||
authService.logout(member, postRefreshTokenDto); | ||
return new ResponseEntity<>(HttpStatusCode.valueOf(200)); | ||
} | ||
|
||
@PostMapping("/reIssuance") | ||
@Operation(summary = "JWT access 토큰 재발급 요청", description = "JWT access 토큰 재발급 요청 API 입니다.") | ||
public GetJwtTokenDto reIssuance(@AuthUser Member member, @RequestBody PostRefreshTokenDto postRefreshTokenDto) { | ||
return authService.reIssuance(member, postRefreshTokenDto); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package Ness.Backend.domain.auth; | ||
|
||
import Ness.Backend.domain.auth.dto.request.PostRefreshTokenDto; | ||
import Ness.Backend.domain.auth.dto.response.GetJwtTokenDto; | ||
import Ness.Backend.domain.auth.inmemory.RefreshTokenRepository; | ||
import Ness.Backend.domain.auth.inmemory.RefreshTokenService; | ||
import Ness.Backend.domain.auth.jwt.JwtTokenProvider; | ||
import Ness.Backend.domain.member.entity.Member; | ||
import Ness.Backend.global.error.ErrorCode; | ||
import Ness.Backend.global.error.exception.UnauthorizedException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.Date; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AuthService { | ||
private final JwtTokenProvider jwtTokenProvider; | ||
private final RefreshTokenRepository refreshTokenRepository; | ||
private final RefreshTokenService refreshTokenService; | ||
|
||
@Transactional | ||
public void logout(Member member, PostRefreshTokenDto postRefreshTokenDto) { | ||
/* refreshToken 만료 여부 확인 */ | ||
if(refreshTokenRepository.findRefreshTokenByJwtRefreshToken(postRefreshTokenDto.getJwtRefreshToken()).isEmpty()){ | ||
throw new UnauthorizedException(ErrorCode.INVALID_REFRESH_TOKEN); | ||
} | ||
|
||
refreshTokenService.removeRefreshToken(postRefreshTokenDto.getJwtRefreshToken()); | ||
SecurityContextHolder.clearContext(); | ||
} | ||
|
||
@Transactional | ||
public GetJwtTokenDto reIssuance(Member member, PostRefreshTokenDto postRefreshTokenDto) { | ||
/* refreshToken 유효성 확인 */ | ||
String refreshToken = postRefreshTokenDto.getJwtRefreshToken().substring(7); | ||
|
||
if (!jwtTokenProvider.validRefreshToken(refreshToken)) { | ||
throw new UnauthorizedException(ErrorCode.INVALID_TOKEN); | ||
} | ||
|
||
/* refreshToken 만료 여부 확인 */ | ||
if(refreshTokenRepository.findRefreshTokenByJwtRefreshToken(postRefreshTokenDto.getJwtRefreshToken()).isEmpty()){ | ||
throw new UnauthorizedException(ErrorCode.INVALID_REFRESH_TOKEN); | ||
} | ||
|
||
final GetJwtTokenDto generateToken = GetJwtTokenDto.builder() | ||
.jwtAccessToken("Bearer " + jwtTokenProvider.generateAccessToken(member.getEmail(), new Date())) | ||
.jwtRefreshToken(postRefreshTokenDto.getJwtRefreshToken()) | ||
.build(); | ||
|
||
return generateToken; | ||
} | ||
|
||
|
||
} |
20 changes: 0 additions & 20 deletions
20
src/main/java/Ness/Backend/domain/auth/dto/LoginRequestDto.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/main/java/Ness/Backend/domain/auth/dto/RegisterRequestDto.java
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
src/main/java/Ness/Backend/domain/auth/dto/ResourceDto.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/main/java/Ness/Backend/domain/auth/dto/request/PostRefreshTokenDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package Ness.Backend.domain.auth.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
public class PostRefreshTokenDto { | ||
@NotNull | ||
private String jwtRefreshToken; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/Ness/Backend/domain/auth/dto/response/GetJwtTokenDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package Ness.Backend.domain.auth.dto.response; | ||
|
||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@NoArgsConstructor | ||
public class GetJwtTokenDto { | ||
private String jwtAccessToken; | ||
private String jwtRefreshToken; | ||
|
||
@Builder | ||
public GetJwtTokenDto(String jwtAccessToken, String jwtRefreshToken) { | ||
this.jwtAccessToken = jwtAccessToken; | ||
this.jwtRefreshToken = jwtRefreshToken; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.