-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[A팀] 백엔드 파트 코드리뷰용 PR #44
base: review
Are you sure you want to change the base?
Changes from all commits
ae88be9
f535789
41581b2
7d0e78d
31c71ce
282e256
c8fe78b
3cc7859
a61e331
238a4e4
3cb64aa
3d67cc9
0aefdfb
49d058d
7a01018
4fc1a90
fda4d34
7742944
3cfd8ab
ab694a6
e55141a
f633563
9da1e1d
5b896d7
f9ae85f
f19434f
d19bc16
95bfc75
b3f3bec
7ccc4a8
2f1fa1b
c2edea9
4694804
72cc845
c8ff388
9081127
5cfba9d
ff9d217
9ec6c8a
2f5db3d
249e6d1
69de32c
bcd5bac
9340389
317ce34
f3c7775
d907b78
c9d74ec
97a89fb
5ae0048
5834563
bb4810a
ce17790
b6e1a8f
39415a8
2be759c
67fc44f
3b2a6bc
d034a07
4f74584
fda923e
a8ba29b
45550b0
92c73f5
a6a64f1
cee7fb5
0c64819
93cefa0
98d251b
746e5a7
5a37a11
a9691b4
950f34a
2daecfa
43576de
a28c9c1
b6d3c39
9d8b270
09f0948
4d5577e
0409935
597d0f2
1a1c463
7cea48e
df2209c
e9637a3
9c12e6b
942b590
cfdc113
0cdb620
2b9a992
69f4a72
1a8998a
1c8d74b
c13ea0e
d55405e
cf988a7
66ec312
070c4bd
f94cf7e
137ae58
bf255d5
86439ad
c53e163
3858784
cbc8eae
9a84255
9f59210
eaeb161
b775043
db28635
1ecfcd8
c689d7f
903570c
09147ec
538d7de
5987e4b
5b4e6bc
2455f76
482ac59
a70d2bb
c1fed80
c4616ee
90e0220
7c7df4d
042bf9f
fffd777
e19a06d
badd7ab
edbf7f5
698df41
5ec3dba
580a1a4
c0271c2
b63b3dd
122bd1a
1b3458f
7f721d0
2f1729d
ee2de0a
cddfe77
5ee0b96
0feced8
3a037a5
e03ec33
7d3f087
837acec
66280fe
5401e3a
7fa1fa8
c11dead
d1bb474
3b51999
7f056d6
4f67ab2
a8162d2
c33a694
778c907
7014fe5
baf1be7
52be5e9
1eb5c78
9c9368e
7bb228c
bf0e674
ac64946
269f5b2
f01f5a8
94be674
27840b3
4b857c2
7364e45
0a2346c
6cd234b
f98dab6
64f23da
190d04d
ddbcbbe
a2abe34
71008a6
411063c
248d23b
4e8eb25
762a580
266fda2
68aeeb8
72f5359
291828d
e946bd8
24b5cf1
7662a57
64cfbd1
8250368
9cf4482
298e83d
76d9a22
fa646c9
681031c
d449919
8459b71
b99e1b9
dc35c6d
1549c66
d86f137
93c8307
a0dc031
2d598ee
ff3d805
ca34265
e7f3303
56d7253
7461b4f
07d5dfd
85e5a5d
b1ac982
9a0bb00
6197da0
460e2d8
e28e7e7
fb4c60f
3041554
1ca0d23
52aba67
2676329
e8ea9b8
c0b28da
d0334d0
6812ace
8afbe93
19f4d72
3315ffc
c160622
16bae29
70236d4
03a3b3a
0d69526
c949bc6
43b4a29
dc25003
37d9f99
80bf507
c82c786
9848cbb
b5ab078
ea1dab7
82cc89c
97e8ff0
ebac955
086cf61
fe00c09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: "\bIssue 생성 템플릿" | ||
about: 해당 Issue 생성 템플릿을 통하여 Issue를 생성해주세요. | ||
title: 'ex) 깃모지 [feat] : Issue 제목' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
### 📝 Description | ||
|
||
- 구현할 내용 1 | ||
- 구현할 내용 2 | ||
|
||
--- | ||
|
||
### 📝 Todo | ||
|
||
- [ ] 구현할 내용 1 | ||
- [ ] 구현할 내용 2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## ✅ PR 유형 | ||
어떤 변경 사항이 있었나요? | ||
|
||
- [ ] 새로운 기능 추가 | ||
- [ ] 버그 수정 | ||
- [ ] 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경) | ||
- [ ] 코드 리팩토링 | ||
- [ ] 주석 추가 및 수정 | ||
- [ ] 문서 수정 | ||
- [ ] 빌드 부분 혹은 패키지 매니저 수정 | ||
- [ ] 파일 혹은 폴더명 수정 | ||
- [ ] 파일 혹은 폴더 삭제 | ||
|
||
--- | ||
|
||
## 📝 작업 내용 | ||
이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능) | ||
|
||
- 작업한 내용 1 | ||
- 작업한 내용 2 | ||
|
||
--- | ||
|
||
## ✏️ 관련 이슈 | ||
본인이 작업한 내용이 어떤 Issue Number와 관련이 있는지만 작성해주세요 | ||
|
||
ex) | ||
- Fixes : #00 (수정중인 이슈) | ||
- Resolves : #100 (무슨 이슈를 해결했는지) | ||
- Ref : #00 #01 (참고할 이슈) | ||
- Related to : #00 #01 (해당 커밋과 관려) | ||
|
||
--- | ||
|
||
## 🎸 기타 사항 or 추가 코멘트 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Hitzone CI/CD with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "main", "develop" ] | ||
pull_request: | ||
branches: [ "main", "develop" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: ⏱️Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: ⏱️Gradle Caching - 빌드 시간 향상 | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
|
||
- name: ⏱️gradle build를 위한 권한을 부여합니다. | ||
run: chmod +x gradlew | ||
|
||
- name: ⏱️gradle build 중입니다. | ||
run: ./gradlew clean build openapi3 asciidoctor | ||
|
||
- name: ⏱️NCP Container Registry에 로그인 후, docker image build 후 NCP Container Registry에 push합니다. | ||
run: | | ||
docker login -u ${{ secrets.NCP_API_ACCESS_KEY }} -p ${{ secrets.NCP_API_SECRET_KEY }} ${{secrets.NCP_CONTAINER_REGISTRY_PUBLIC_ENDPOINT}} | ||
docker build -f Dockerfile -t ${{ secrets.NCP_CONTAINER_REGISTRY_PUBLIC_ENDPOINT }}/${{ secrets.NCP_CONTAINER_REGISTRY_IMAGE }} . | ||
docker push ${{ secrets.NCP_CONTAINER_REGISTRY_PUBLIC_ENDPOINT }}/${{ secrets.NCP_CONTAINER_REGISTRY_IMAGE }} | ||
|
||
- name: ⏱️NCP Container Registry에서 pull 후 deploy합니다. | ||
uses: appleboy/ssh-action@master | ||
with: | ||
username: ${{ secrets.NCP_SERVER_USERNAME }} | ||
password: ${{ secrets.NCP_SERVER_PASSWORD }} | ||
host: ${{ secrets.NCP_SERVER_HOST }} | ||
script: | | ||
chmod 777 ./deploy.sh | ||
./deploy.sh | ||
docker image prune -f |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,7 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
.DS_Store | ||
|
||
src/main/resources/static/docs/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 최종 이미지 단계 | ||
FROM openjdk:17-jdk-alpine as final | ||
|
||
WORKDIR /app | ||
|
||
# 빌드된 JAR 파일과 정적 문서 파일을 복사 | ||
COPY ./build/libs/backend-0.0.1-SNAPSHOT.jar app.jar | ||
COPY ./build/resources/main/static/docs /app/static/docs | ||
|
||
# HEALTHCHECK 추가 | ||
HEALTHCHECK --interval=5s --timeout=3s --start-period=30s --retries=3 \ | ||
CMD curl --fail http://localhost:8080 || exit 1 | ||
|
||
ENTRYPOINT ["java", "-jar", "app.jar"] | ||
|
||
EXPOSE 8080 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
rootProject.name = 'bakend' | ||
rootProject.name = 'backend' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package kusitms.bakend; | ||
package kusitms.backend; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class BakendApplication { | ||
public class BackendApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(BakendApplication.class, args); | ||
SpringApplication.run(BackendApplication.class, args); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package kusitms.backend.auth.application; | ||
|
||
import jakarta.servlet.http.HttpServletResponse; | ||
import kusitms.backend.auth.jwt.JWTUtil; | ||
import kusitms.backend.auth.status.AuthErrorStatus; | ||
import kusitms.backend.global.exception.CustomException; | ||
import kusitms.backend.global.redis.RedisManager; | ||
import kusitms.backend.global.util.CookieUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class AuthService { | ||
|
||
@Value("${spring.jwt.access-token.expiration-time}") | ||
private long ACCESS_TOKEN_EXPIRATION_TIME; | ||
|
||
@Value("${spring.jwt.refresh-token.expiration-time}") | ||
private long REFRESH_TOKEN_EXPIRATION_TIME; | ||
|
||
private final JWTUtil jwtUtil; | ||
private final RedisManager redisManager; | ||
|
||
@Transactional | ||
public void reIssueToken(String refreshToken, HttpServletResponse response) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. application layer는 어떤 프로토콜이 사용되는지 몰라도 동작할 수 있어야 하기 때문에 알 필요가 없다고 생각합니다! |
||
if (refreshToken == null) { | ||
throw new CustomException(AuthErrorStatus._EXPIRED_REFRESH_TOKEN); | ||
} | ||
Long userId = jwtUtil.getUserIdFromToken(refreshToken); | ||
String storedRefreshToken = redisManager.getRefreshToken(userId.toString()); | ||
if (!storedRefreshToken.equals(refreshToken)){ | ||
throw new CustomException(AuthErrorStatus._TOKEN_USER_MISMATCH); | ||
} | ||
|
||
jwtUtil.validateRefreshToken(storedRefreshToken); | ||
String newAccessToken = jwtUtil.generateToken(userId, ACCESS_TOKEN_EXPIRATION_TIME); // 1시간 유효기간 | ||
String newRefreshToken = jwtUtil.generateToken(userId, REFRESH_TOKEN_EXPIRATION_TIME); // 14일 유효기간 | ||
redisManager.saveRefreshToken(userId.toString(), newRefreshToken); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DB 트랜잭션(
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 잘 모르는 부분들이 많아 학습하느라 답변이 늦었습니다..! 양질의 코드리뷰 감사드립니다 🙇🏻♂️🙇🏻♂️
|
||
|
||
CookieUtil.setCookie(response, "accessToken", newAccessToken, (int) (ACCESS_TOKEN_EXPIRATION_TIME * 1.5) / 1000); | ||
CookieUtil.setCookie(response, "refreshToken", newRefreshToken, (int) REFRESH_TOKEN_EXPIRATION_TIME / 1000); | ||
CookieUtil.setNotHttpOnlyCookie(response, "expirationTime", String.valueOf((int) ACCESS_TOKEN_EXPIRATION_TIME / 1000), (int) (ACCESS_TOKEN_EXPIRATION_TIME * 1.5) / 1000); | ||
Comment on lines
+45
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cookie에 값을 세팅하는게 application layer의 역할일까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. application layer는 비즈니스 로직을 담당하는데, 클라이언트와의 프로토콜은 컨트롤러 또는 외부 경계에서 처리하는 것이 좋다고 합니다! 기존에는 HTTP 프로토콜만을 처리할 수 있는 메서드이기에, 이를 분리해서 확장성을 높여야 할 것 같습니다. |
||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package kusitms.backend.auth.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
import java.util.Map; | ||
|
||
@AllArgsConstructor | ||
public class GoogleUserInfo implements OAuth2UserInfo { | ||
|
||
private final Map<String, Object> attribute; | ||
|
||
@Override | ||
public String getProvider() { | ||
return "google"; | ||
} | ||
|
||
@Override | ||
public String getProviderId() { | ||
return attribute.get("sub").toString(); | ||
} | ||
|
||
@Override | ||
public String getEmail() { | ||
return attribute.get("email").toString(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return attribute.get("name").toString(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Transactional이 필요한 로직일까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
불필요한 로직인 것 같아 제거하겠습니다..!
#79