Skip to content

Commit 7ec238c

Browse files
authored
Deploy: Merge to main
1 parent 638843f commit 7ec238c

File tree

8 files changed

+57
-35
lines changed

8 files changed

+57
-35
lines changed

.github/workflows/ci-cd.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,14 @@ jobs:
3434
JAR=$(ls build/libs/*.jar | head -n 1)
3535
cp "$JAR" app.jar
3636
37-
- name: Create Firebase service account file
38-
run: |
39-
mkdir -p firebase
40-
echo "${{ secrets.FCM }}" > firebase/tinybite_fcm.json
41-
4237
- name: Compute image name (change to lowercase)
4338
id: img
4439
run: echo "name=${{ env.REGISTRY }}/${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
4540

46-
- name: Log in to GHCR
41+
- name: Log in to GHCR registry: ${{ env.REGISTRY }}
42+
4743
uses: docker/login-action@v3
4844
with:
49-
registry: ${{ env.REGISTRY }}
5045
username: ${{ github.actor }}
5146
password: ${{ secrets.GHCR_TOKEN }}
5247

src/main/java/ita/tinybite/domain/auth/dto/request/GoogleAndAppleSignupRequest.java

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

33
import ita.tinybite.domain.user.constant.PlatformType;
44
import jakarta.validation.constraints.NotBlank;
5+
import jakarta.validation.constraints.NotNull;
56

67
public record GoogleAndAppleSignupRequest(
78
@NotBlank(message = "idToken은 필수입니다")
@@ -12,7 +13,7 @@ public record GoogleAndAppleSignupRequest(
1213
String nickname,
1314
@NotBlank(message = "위치 정보 필수입니다")
1415
String location,
15-
@NotBlank(message = "플랫폼정보는 필수입니다")
16+
@NotNull(message = "플랫폼정보는 필수입니다")
1617
PlatformType platform
1718
) {
1819
}

src/main/java/ita/tinybite/domain/auth/service/AuthService.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import lombok.extern.slf4j.Slf4j;
2727

2828
import org.springframework.beans.factory.annotation.Value;
29+
import org.springframework.security.oauth2.jwt.Jwt;
2930
import org.springframework.security.oauth2.jwt.JwtDecoder;
31+
import org.springframework.security.oauth2.jwt.JwtException;
3032
import org.springframework.stereotype.Service;
3133
import org.springframework.transaction.annotation.Transactional;
3234

@@ -47,8 +49,8 @@ public class AuthService {
4749
private final JwtDecoder appleJwtDecoder;
4850
private final NicknameGenerator nicknameGenerator;
4951

50-
// @Value("${apple.client-id}")
51-
// private String appleClientId;
52+
@Value("${apple.client-id}")
53+
private String appleClientId;
5254

5355
@Value("${google.android-id}")
5456
private String googleAndroidId;
@@ -224,10 +226,35 @@ private String getEmailFromIdToken(String idToken, PlatformType platformType, Lo
224226

225227
} catch (GeneralSecurityException | IOException e) {
226228
throw BusinessException.of(AuthErrorCode.GOOGLE_LOGIN_ERROR);
229+
} catch (Exception e) {
230+
throw BusinessException.of(AuthErrorCode.INVALID_TOKEN);
227231
}
228232
}
229233
case APPLE -> {
230-
//TODO Apple 구현 예정
234+
String clientId = appleClientId;
235+
236+
try {
237+
Jwt jwt = appleJwtDecoder.decode(idToken);
238+
239+
if(!"https://appleid.apple.com".equals(jwt.getIssuer().toString())) {
240+
throw BusinessException.of(AuthErrorCode.INVALID_TOKEN);
241+
}
242+
243+
String aud = jwt.getAudience().get(0);
244+
if (!aud.equals(clientId)) {
245+
throw BusinessException.of(AuthErrorCode.INVALID_TOKEN);
246+
}
247+
248+
Object emailObject = jwt.getClaims().get("email");
249+
if(emailObject == null) {
250+
throw BusinessException.of(AuthErrorCode.NOT_EXISTS_EMAIL);
251+
}
252+
return emailObject.toString();
253+
} catch (JwtException e) {
254+
throw BusinessException.of(AuthErrorCode.INVALID_TOKEN);
255+
} catch (Exception e) {
256+
throw BusinessException.of(AuthErrorCode.APPLE_LOGIN_ERROR);
257+
}
231258
}
232259
}
233260
return null;

src/main/java/ita/tinybite/global/config/FcmConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import jakarta.annotation.PostConstruct;
1717
import lombok.extern.slf4j.Slf4j;
18-
import org.springframework.core.io.FileSystemResource;
1918

2019
@Slf4j
2120
@Configuration
@@ -31,7 +30,7 @@ public void initialize() {
3130
return;
3231
}
3332
try {
34-
ClassPathResource resource = new ClassPathResource(fcmConfigPath);
33+
ClassPathResource resource = new ClassPathResource(fcmConfigPath);
3534
try (InputStream stream = resource.getInputStream()) {
3635
FirebaseOptions options = FirebaseOptions.builder()
3736
.setCredentials(GoogleCredentials.fromStream(stream))

src/main/java/ita/tinybite/global/exception/errorcode/AuthErrorCode.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public enum AuthErrorCode implements ErrorCode {
1616
GOOGLE_LOGIN_ERROR(HttpStatus.BAD_REQUEST, "GOOGLE_LOGIN_ERROR", "구글 로그인 중 에러가 발생했습니다."),
1717
APPLE_LOGIN_ERROR(HttpStatus.BAD_REQUEST, "APPLE_LOGIN_ERROR", "애플 로그인 중 에러가 발생했습니다."),
1818

19-
INVALID_PLATFORM(HttpStatus.BAD_REQUEST, "INVALID_PLATFORM", "올바른 플랫폼이 아닙니다. (Android, iOS)");
19+
INVALID_PLATFORM(HttpStatus.BAD_REQUEST, "INVALID_PLATFORM", "올바른 플랫폼이 아닙니다. (Android, iOS)"),
20+
NOT_EXISTS_EMAIL(HttpStatus.BAD_REQUEST, "NOT_EXISTS_EMAIL", "애플 이메일이 존재하지 않습니다.")
21+
;
2022

2123
private final HttpStatus httpStatus;
2224
private final String code;

src/main/resources/application-dev.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spring:
1212
jpa:
1313
show-sql: true
1414
hibernate:
15-
ddl-auto: create-drop # 개발: update, 운영: validate 또는 none
15+
ddl-auto: update # 개발: update, 운영: validate 또는 none
1616

1717
data:
1818
redis:
@@ -22,10 +22,3 @@ spring:
2222
kakao:
2323
client-id: ${KAKAO_CLIENT_ID}
2424
redirect-uri: ${KAKAO_REDIRECT_URI}
25-
26-
naver:
27-
client-id: ${NAVER_CLIENT_ID}
28-
secret: ${NAVER_CLIENT_SECRET}
29-
30-
fcm:
31-
file_path: ${DEV_FCM_PATH}

src/main/resources/application-local.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ spring:
2828
kakao:
2929
client-id: ${KAKAO_CLIENT_ID}
3030
redirect-uri: ${KAKAO_REDIRECT_URI}
31+
32+
google:
33+
android-id: ${GOOGLE_ANDROID_CLIENT_ID}
34+
ios-id: ${GOOGLE_IOS_CLIENT_ID}
3135

32-
naver:
33-
client-id: ${NAVER_CLIENT_ID}
34-
secret: ${NAVER_CLIENT_SECRET}
36+
google:
37+
android-id: ${GOOGLE_ANDROID_CLIENT_ID}
38+
ios-id: ${GOOGLE_IOS_CLIENT_ID}
3539

36-
fcm:
37-
file_path: firebase/tinybite_fcm.json
40+
#apple:
41+
# client-id: ${APPLE_CLIENT_ID}
42+
#
3843

3944
logging:
4045
level:

src/main/resources/application.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ sms:
2121
api-key: ${SMS_API_KEY}
2222
api-secret: ${SMS_API_SECRET}
2323

24+
apple:
25+
client-id: ${APPLE_CLIENT_ID}
26+
27+
naver:
28+
client-id: ${NAVER_CLIENT_ID}
29+
secret: ${NAVER_CLIENT_SECRET}
30+
2431
fcm:
32+
file_path: firebase/tinybite_fcm.json
2533
url: https://fcm.googleapis.com/v1/projects/${FCM_PROJECT_ID}/messages:send
2634
google_api: https://www.googleapis.com/auth/cloud-platform
2735
project_id: ${FCM_PROJECT_ID}
28-
29-
google:
30-
android-id: ${GOOGLE_ANDROID_CLIENT_ID}
31-
ios-id: ${GOOGLE_IOS_CLIENT_ID}
32-
33-
#apple:
34-
# client-id: ${APPLE_CLIENT_ID}
35-
#

0 commit comments

Comments
 (0)