From 040f82a3589215dddfae4035eed5cbaf96adb57a Mon Sep 17 00:00:00 2001 From: elive7 Date: Mon, 18 Nov 2024 21:04:05 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[hotfix]=20fix:=20interceptor=20profile=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/authentication/interceptor/DeviceIdInterceptor.java | 2 +- .../interceptor/VersionVerificationInterceptor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/DeviceIdInterceptor.java b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/DeviceIdInterceptor.java index bcfed90e..d437a9ce 100644 --- a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/DeviceIdInterceptor.java +++ b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/DeviceIdInterceptor.java @@ -10,7 +10,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.HandlerInterceptor; -@Profile({"dev", "local"}) +@Profile({"dev", "prod"}) @Component @Transactional @RequiredArgsConstructor diff --git a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java index e8f85c5e..ea05f2f7 100644 --- a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java +++ b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.servlet.HandlerInterceptor; -@Profile({"dev", "local"}) +@Profile({"dev", "prod", }) @Component public class VersionVerificationInterceptor implements HandlerInterceptor { From 42977a5fb057100229fe167242645d44e32af1eb Mon Sep 17 00:00:00 2001 From: elive7 Date: Mon, 18 Nov 2024 21:21:18 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[hotfix]=20fix:=20version=20=EB=B9=84?= =?UTF-8?q?=EA=B5=90=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VersionVerificationInterceptor.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java index ea05f2f7..a0a9b39d 100644 --- a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java +++ b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java @@ -24,7 +24,7 @@ public VersionVerificationInterceptor( @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { try { - if (!request.getHeader("App-Version").equals(version)) { + if (compareVersions(request.getHeader("App-Version"), version) < 0) { throw new UpdateRequiredException(); } } catch (NullPointerException e) { @@ -33,4 +33,23 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons return true; } + + private static int compareVersions(String version1, String version2) { + String[] v1Parts = version1.split("\\."); + String[] v2Parts = version2.split("\\."); + + int length = Math.max(v1Parts.length, v2Parts.length); + + for (int i = 0; i < length; i++) { + int v1Part = i < v1Parts.length ? Integer.parseInt(v1Parts[i]) : 0; + int v2Part = i < v2Parts.length ? Integer.parseInt(v2Parts[i]) : 0; + + if (v1Part < v2Part) { + return -1; + } else if (v1Part > v2Part) { + return 1; + } + } + return 0; + } } From db1b9d67af7e2a92c1dd5b5bccfc47eb3b829fad Mon Sep 17 00:00:00 2001 From: elive7 Date: Mon, 18 Nov 2024 21:04:05 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[hotfix]=20fix:=20interceptor=20profile=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/authentication/interceptor/DeviceIdInterceptor.java | 2 +- .../interceptor/VersionVerificationInterceptor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/DeviceIdInterceptor.java b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/DeviceIdInterceptor.java index bcfed90e..d437a9ce 100644 --- a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/DeviceIdInterceptor.java +++ b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/DeviceIdInterceptor.java @@ -10,7 +10,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.HandlerInterceptor; -@Profile({"dev", "local"}) +@Profile({"dev", "prod"}) @Component @Transactional @RequiredArgsConstructor diff --git a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java index e8f85c5e..ea05f2f7 100644 --- a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java +++ b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.servlet.HandlerInterceptor; -@Profile({"dev", "local"}) +@Profile({"dev", "prod", }) @Component public class VersionVerificationInterceptor implements HandlerInterceptor { From b0785f9e1745422f5d58a1ad7052692c58fe6b92 Mon Sep 17 00:00:00 2001 From: elive7 Date: Mon, 18 Nov 2024 21:21:18 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[hotfix]=20fix:=20version=20=EB=B9=84?= =?UTF-8?q?=EA=B5=90=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VersionVerificationInterceptor.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java index ea05f2f7..a0a9b39d 100644 --- a/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java +++ b/src/main/java/com/projectlyrics/server/domain/auth/authentication/interceptor/VersionVerificationInterceptor.java @@ -24,7 +24,7 @@ public VersionVerificationInterceptor( @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { try { - if (!request.getHeader("App-Version").equals(version)) { + if (compareVersions(request.getHeader("App-Version"), version) < 0) { throw new UpdateRequiredException(); } } catch (NullPointerException e) { @@ -33,4 +33,23 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons return true; } + + private static int compareVersions(String version1, String version2) { + String[] v1Parts = version1.split("\\."); + String[] v2Parts = version2.split("\\."); + + int length = Math.max(v1Parts.length, v2Parts.length); + + for (int i = 0; i < length; i++) { + int v1Part = i < v1Parts.length ? Integer.parseInt(v1Parts[i]) : 0; + int v2Part = i < v2Parts.length ? Integer.parseInt(v2Parts[i]) : 0; + + if (v1Part < v2Part) { + return -1; + } else if (v1Part > v2Part) { + return 1; + } + } + return 0; + } }