Skip to content

Commit ee0d871

Browse files
committed
chore: resolve merge conflict
2 parents 0ee72e7 + e47f226 commit ee0d871

40 files changed

+825
-328
lines changed

.github/workflows/gradle.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
7+
8+
name: Java CI with Gradle
9+
10+
on:
11+
push:
12+
branches: [ "main" ]
13+
14+
jobs:
15+
#Build
16+
build:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
21+
steps:
22+
## 체크아웃
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
with:
26+
token: ${{ secrets.TOKEN }}
27+
submodules: true
28+
## JDK 17
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: '17'
33+
distribution: 'temurin'
34+
35+
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
36+
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
37+
38+
## Gradle build (Test 제외)
39+
- name: Build with Gradle
40+
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
41+
with:
42+
arguments: clean build -x test
43+
44+
## Docker build & push
45+
- name: Docker build and push
46+
run: |
47+
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
48+
docker build -t ${{ secrets.DOCKERHUB_REPOSITORY }} .
49+
docker tag ${{ secrets.DOCKERHUB_REPOSITORY }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7}
50+
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7}
51+
52+
#Deploy
53+
deploy:
54+
runs-on: ubuntu-latest
55+
needs: build
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v3
59+
60+
- name: Deploy
61+
uses: appleboy/ssh-action@master
62+
with:
63+
host: ${{ secrets.VM_INSTANCE }}
64+
username: ${{ secrets.SSH_USERNAME }}
65+
key: ${{ secrets.SSH_PRIVATE_KEY }}
66+
envs: GITHUB_SHA
67+
script: |
68+
sudo docker-compose down
69+
sudo docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
70+
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7}
71+
sudo docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7} donut
72+
sudo docker-compose up -d --remove-orphans

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,4 @@ out/
4040
.vscode/
4141

4242
### gcs access iam ###
43-
adroit-metric-413519-7d23d8bb1152.json
44-
adroit-metric-413519-d4e6d7038d34.json
43+
*.json

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "Donut-Server-yml"]
2+
path = Donut-Server-yml
3+
url = https://github.com/Donut-DONationUTile/Donut-Server-yml.git

Donut-Server-yml

Submodule Donut-Server-yml added at 8c5345a

build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ dependencies {
5555
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
5656
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
5757
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
58+
//WebClient
59+
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-webflux'
5860

5961
}
6062

@@ -64,6 +66,16 @@ dependencyManagement {
6466
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
6567
}
6668
}
69+
70+
//yml submodule
71+
task copyYML(type: Copy){
72+
copy{
73+
from './Donut-Server-yml'
74+
include "*.yml" , "*.json"
75+
into './src/main/resources'
76+
}
77+
}
78+
6779
tasks.named('test') {
6880
useJUnitPlatform()
6981
}

src/main/java/zero/eight/donut/DonutApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
6+
import org.springframework.scheduling.annotation.EnableScheduling;
67

8+
@EnableScheduling
79
@EnableJpaAuditing
810
@SpringBootApplication
911
public class DonutApplication {

src/main/java/zero/eight/donut/service/AuthUtils.java renamed to src/main/java/zero/eight/donut/config/jwt/AuthUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package zero.eight.donut.service;
1+
package zero.eight.donut.config.jwt;
22

33
import lombok.RequiredArgsConstructor;
4+
import lombok.extern.slf4j.Slf4j;
45
import org.springframework.security.core.Authentication;
56
import org.springframework.security.core.GrantedAuthority;
67
import org.springframework.security.core.context.SecurityContextHolder;
@@ -14,6 +15,7 @@
1415

1516
import java.util.Collection;
1617

18+
@Slf4j
1719
@RequiredArgsConstructor
1820
@Component
1921
public class AuthUtils {
@@ -24,6 +26,8 @@ public class AuthUtils {
2426
private final ReceiverRepository receiverRepository;
2527

2628
public Giver getGiver() {
29+
log.info("사용자 이메일 -> {}", getCurrentUserEmail());
30+
log.info("사용자 -> {}", giverRepository.findByEmail(getCurrentUserEmail()));
2731
return giverRepository.findByEmail(getCurrentUserEmail()).get();
2832
}
2933

src/main/java/zero/eight/donut/config/jwt/JwtUtils.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.jsonwebtoken.*;
44
import jakarta.servlet.http.HttpServletRequest;
55
import lombok.RequiredArgsConstructor;
6+
import lombok.extern.slf4j.Slf4j;
67
import org.springframework.beans.factory.annotation.Value;
78
import org.springframework.data.redis.core.StringRedisTemplate;
89
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -21,14 +22,15 @@
2122
import java.util.Date;
2223
import java.util.concurrent.TimeUnit;
2324

25+
@Slf4j
2426
@RequiredArgsConstructor
2527
@Component
2628
public class JwtUtils {
2729

2830
@Value("${secret.time.access}")
29-
private long accessTokenTime; // 30분;
31+
private long accessTokenTime; // 30일
3032
@Value("${secret.time.refresh}")
31-
private long refreshTokenTime; // 14일;
33+
private long refreshTokenTime; // 30일
3234
@Value("${secret.key}")
3335
private String jwtSecretKey;
3436
private final StringRedisTemplate stringRedisTemplate;
@@ -88,11 +90,15 @@ public boolean validateToken(String token) {
8890
}
8991
try {
9092
Claims claims = Jwts.parser().setSigningKey(jwtSecretKey).parseClaimsJws(token).getBody();
93+
log.info("token \"role\" : " + claims.get("role"));
94+
log.info("token \"name\" : " + claims.get("name"));
9195
return true;
9296
} catch (MalformedJwtException e) {
9397
throw new UnauthorizedException(Error.INVALID_JWT_EXCEPTION);
9498
} catch (ExpiredJwtException e) {
9599
throw new UnauthorizedException(Error.JWT_EXPIRED);
100+
} catch (UnauthorizedException e) {
101+
return false;
96102
}
97103
}
98104

src/main/java/zero/eight/donut/controller/AuthController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import zero.eight.donut.common.response.ApiResponse;
99
import zero.eight.donut.dto.auth.AuthRequestDto;
1010
import zero.eight.donut.dto.auth.AuthTestDto;
11+
import zero.eight.donut.dto.auth.GoogleLoginDto;
1112
import zero.eight.donut.service.AuthService;
1213

1314
@Slf4j
@@ -19,8 +20,8 @@ public class AuthController {
1920

2021
// 기부자 구글 로그인
2122
@PostMapping("/giver/signin")
22-
public ApiResponse<?> googleSignIn() {
23-
return authService.googleSignIn(((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest().getHeader("Authorization"));
23+
public ApiResponse<?> googleSignIn(@RequestBody GoogleLoginDto googleLoginDto) {
24+
return authService.googleSignIn(googleLoginDto.getIdToken());
2425
}
2526

2627
@PostMapping("/giver/test")

src/main/java/zero/eight/donut/controller/DonationController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.RequiredArgsConstructor;
44
import org.springframework.web.bind.annotation.PostMapping;
5+
import org.springframework.web.bind.annotation.RequestBody;
56
import org.springframework.web.bind.annotation.RequestMapping;
67
import org.springframework.web.bind.annotation.RestController;
78
import zero.eight.donut.common.response.ApiResponse;
@@ -19,7 +20,7 @@ public class DonationController {
1920
private final DonationService donationService;
2021

2122
@PostMapping("/receiver/assign")
22-
public ApiResponse<?> assignGiftbox(GiftboxRequestDto giftboxRequestDto) {
23+
public ApiResponse<?> assignGiftbox(@RequestBody GiftboxRequestDto giftboxRequestDto) {
2324
return donationService.assignGiftbox(giftboxRequestDto);
2425
}
2526

0 commit comments

Comments
 (0)