Skip to content
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

Feat #133 코틀린 마이그레이션 (build.gradle -> build.gradle.kts 로 변경, 의존성 버전 변경) #132

Merged
merged 9 commits into from
Jan 5, 2024
Merged
1 change: 0 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Modular Monolithic 아키텍처이므로, 다음과 같은 모듈들로 구성
| Payment-Api | 주문한 상품에 대한 결제 처리 및 취소를 담당하는 모듈입니다. |
| Product-Api | 상품을 관리하고 사용자에게 노출하는 기능을 담당하는 모듈입니다. |
| Point-Api | (추가예정) |
| Purchase-Api | (대체예정) |

각 도메인 모듈은 하위에 아래와 같이 Layered Architecture 형식의 Build Artifacts로 분리되어 구성됩니다.

Expand Down
14 changes: 0 additions & 14 deletions account-api/account-application/build.gradle

This file was deleted.

18 changes: 18 additions & 0 deletions account-api/account-application/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
}

tasks.jar {
enabled = true
}

tasks.bootJar {
enabled = false
}

dependencies {
implementation(project(":account-api:account-domain"))
implementation(project(":common"))
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
}
8 changes: 0 additions & 8 deletions account-api/account-domain/build.gradle

This file was deleted.

16 changes: 16 additions & 0 deletions account-api/account-domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
tasks.jar {
enabled = true
}

tasks.bootJar {
enabled = false
}

dependencies {
implementation(project(":common"))
implementation("jakarta.persistence:jakarta.persistence-api:${Version.jakartaPersistenceApi}")
implementation("org.hibernate:hibernate-core:${Version.hibernateCore}")
testImplementation("org.assertj:assertj-core")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
21 changes: 0 additions & 21 deletions account-api/account-infrastructure/build.gradle

This file was deleted.

25 changes: 25 additions & 0 deletions account-api/account-infrastructure/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
}

tasks.jar {
enabled = true
}

tasks.bootJar {
enabled = false
}

dependencies {
implementation(project(":account-api:account-domain"))
implementation(project(":common"))
implementation("io.jsonwebtoken:jjwt-api:${Version.jjwt}")
implementation("io.jsonwebtoken:jjwt-impl:${Version.jjwt}")
implementation("io.jsonwebtoken:jjwt-jackson:${Version.jjwt}")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-security")
testImplementation("org.springframework.boot:spring-boot-starter-test")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
package kr.flab.movieon.account.infrastructure.jwt.impl;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.MalformedJwtException;
import io.jsonwebtoken.UnsupportedJwtException;
import io.jsonwebtoken.*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아마 이렇게 하면 나중에 Kotlin의 Ktlint가 wildcards import에 대해 싫은 소리를 할 거 같긴 한데... wildcards import로 싫은 소리 못하게 rule을 추가해버리죠ㅋㅋ

Copy link
Collaborator Author

@JiwonDev JiwonDev Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 이거 IntelliJ가 마음대로 변경해버렸네요. 해당옵션을 꺼놓겠습니다 ㅋㅋㅋㅋ
해당 코드는 어차피 코틀린으로 마이그레이션하면 없어질 예정이니, 당장 수정하지는 않을게요.
image

import io.jsonwebtoken.security.Keys;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.util.List;
import kr.flab.movieon.account.infrastructure.jwt.AlreadyTokenExpiredException;
import kr.flab.movieon.account.infrastructure.jwt.RawToken;
import kr.flab.movieon.account.infrastructure.jwt.TokenParser;
Expand All @@ -18,6 +10,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.crypto.SecretKey;
import java.nio.charset.StandardCharsets;
import java.util.List;

public final class JwtTokenParser implements TokenParser {

private final Logger log = LoggerFactory.getLogger(JwtTokenParser.class);
Expand All @@ -31,17 +27,18 @@ public JwtTokenParser(TokenProperties tokenProperties) {
@Override
public RawToken parse(String token) {
try {
Jws<Claims> jwt = Jwts.parserBuilder()
.setSigningKey(getKey(tokenProperties.getBase64TokenSigningKey()))
.build()
.parseClaimsJws(token);
String jti = (String) jwt.getBody().get("jti");
Jws<Claims> jwt = Jwts.parser()
.verifyWith(getKey(tokenProperties.getBase64TokenSigningKey()))
.build()
.parseSignedClaims(token);

String jti = (String) jwt.getPayload().get("jti");
if (jti == null) {
return new RawToken((String) jwt.getBody().get("email"),
(List<String>) jwt.getBody().get("scopes"));
return new RawToken((String) jwt.getPayload().get("email"),
(List<String>) jwt.getPayload().get("scopes"));
}
return new RawToken((String) jwt.getBody().get("email"), jti,
(List<String>) jwt.getBody().get("scopes"));
return new RawToken((String) jwt.getPayload().get("email"), jti,
(List<String>) jwt.getPayload().get("scopes"));
} catch (UnsupportedJwtException | MalformedJwtException | IllegalArgumentException ex) {
log.error("Invalid JWT Token", ex);
throw new InvalidTokenException();
Expand All @@ -51,7 +48,7 @@ public RawToken parse(String token) {
}
}

private Key getKey(String signKey) {
private SecretKey getKey(String signKey) {
return Keys.hmacShaKeyFor(signKey.getBytes(StandardCharsets.UTF_8));
}
}
19 changes: 0 additions & 19 deletions account-api/account-presentation/build.gradle

This file was deleted.

23 changes: 23 additions & 0 deletions account-api/account-presentation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
}

tasks.jar {
enabled = true
}

tasks.bootJar {
enabled = false
}

dependencies {
implementation(project(":account-api:account-application"))
implementation(project(":common"))
implementation("org.springdoc:springdoc-openapi-ui:${Version.springdocOpenapi}")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-validation")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
65 changes: 0 additions & 65 deletions app/build.gradle

This file was deleted.

57 changes: 57 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
plugins {
JiwonDev marked this conversation as resolved.
Show resolved Hide resolved
id("org.springframework.boot")
id("io.spring.dependency-management")
kotlin("plugin.jpa")
}

tasks.bootJar {
enabled = true
}

dependencies {
implementation(project(":notification-api:notification-presentation"))
implementation(project(":notification-api:notification-application"))
implementation(project(":notification-api:notification-domain"))
implementation(project(":notification-api:notification-infrastructure"))

implementation(project(":account-api:account-presentation"))
implementation(project(":account-api:account-application"))
implementation(project(":account-api:account-domain"))
implementation(project(":account-api:account-infrastructure"))

implementation(project(":order-api:order-presentation"))
implementation(project(":order-api:order-application"))
implementation(project(":order-api:order-domain"))
implementation(project(":order-api:order-infrastructure"))

implementation(project(":payment-api:payment-presentation"))
implementation(project(":payment-api:payment-application"))
implementation(project(":payment-api:payment-domain"))
implementation(project(":payment-api:payment-infrastructure"))

implementation(project(":product-api:product-presentation"))
implementation(project(":product-api:product-application"))
implementation(project(":product-api:product-domain"))
implementation(project(":product-api:product-infrastructure"))

implementation(project(":query-api"))
implementation(project(":common"))

implementation("org.springdoc:springdoc-openapi-ui:${Version.springdocOpenapi}")
implementation("org.springdoc:springdoc-openapi-security:${Version.springdocOpenapi}")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-amqp")
implementation("it.ozimov:embedded-redis:${Version.embeddedRedis}") {
exclude(group = "org.slf4j", module = "slf4j-simple")
}
runtimeOnly("com.mysql:mysql-connector-j")
implementation("org.flywaydb:flyway-mysql")
testImplementation("com.h2database:h2")
testImplementation("com.navercorp.fixturemonkey:fixture-monkey-starter:${Version.fixtureMonkey}")
// com.navercorp.fixturemonkey - org.glassfish:jakarta.el:3.0.3 보안 이슈로 버전 변경 (CVE-2021-28170)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주석에 대한 링크도 같이 걸어주시면 좋을 것 같긴 합니다ㅎㅎ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

링크를 남겨두니까, 오래된 코드에선 한번씩 링크가 유효하지 않은 경우가 있어서 당황스럽더라구요.
여기 PR에다가만 링크로 남겨둘게요!
https://nvd.nist.gov/vuln/detail/CVE-2021-28170

testImplementation("org.glassfish:jakarta.el:3.0.4")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
Loading