This commit is contained in:
Wanda 2025-06-11 09:21:49 +07:00
parent 39e4887b0a
commit f23c20d82b
6 changed files with 61 additions and 43 deletions

@ -6,7 +6,7 @@ plugins {
group = 'id.co.anaheim' group = 'id.co.anaheim'
//version = '0.0.5-SNAPSHOT' //version = '0.0.5-SNAPSHOT'
version = '0.0.6' version = '0.0.13-Prod'
java { java {
toolchain { toolchain {
@ -29,7 +29,6 @@ ext {
} }
dependencies { dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-jdbc' implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-web'
@ -45,7 +44,7 @@ dependencies {
implementation 'io.azam.ulidj:ulidj:1.0.4' implementation 'io.azam.ulidj:ulidj:1.0.4'
implementation 'com.bucket4j:bucket4j-core:8.3.0' implementation 'com.bucket4j:bucket4j-core:8.3.0'
implementation 'org.asynchttpclient:async-http-client:3.0.0' implementation 'org.asynchttpclient:async-http-client:3.0.1'
compileOnly 'org.projectlombok:lombok' compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.oracle.database.jdbc:ojdbc11' runtimeOnly 'com.oracle.database.jdbc:ojdbc11'

BIN
cert/esbuat-djpbdomain.der Normal file

Binary file not shown.

@ -50,7 +50,7 @@ public class JwtAuthFilter extends OncePerRequestFilter {
} else { } else {
BasicResponse basicResponse = new BasicResponse(); BasicResponse basicResponse = new BasicResponse();
basicResponse.setFileName(""); basicResponse.setFileName("");
basicResponse.setResultCode("403"); basicResponse.setResultCode("401");
Gson gson = new Gson(); Gson gson = new Gson();
if (authHeader != null && authHeader.startsWith("Bearer ")) { if (authHeader != null && authHeader.startsWith("Bearer ")) {
String token = authHeader.substring(7); String token = authHeader.substring(7);

@ -32,7 +32,7 @@ public class AuthController {
User user = repository.findByUsername(authDto.getUsername()); User user = repository.findByUsername(authDto.getUsername());
if (user == null) { if (user == null) {
response.setResultCode("403"); response.setResultCode("401");
response.setResultStatus("Tidak Memiliki Otorisasi"); response.setResultStatus("Tidak Memiliki Otorisasi");
description.setMessage("Username/Password tidak sesuai"); description.setMessage("Username/Password tidak sesuai");
} else { } else {
@ -48,7 +48,7 @@ public class AuthController {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
description.setTokenExpiration(dateFormat.format(jwtExpiration.getValue())); description.setTokenExpiration(dateFormat.format(jwtExpiration.getValue()));
} else { } else {
response.setResultCode("403"); response.setResultCode("401");
response.setResultStatus("Tidak Memiliki Otorisasi"); response.setResultStatus("Tidak Memiliki Otorisasi");
description.setMessage("Username/Password tidak sesuai"); description.setMessage("Username/Password tidak sesuai");
} }

@ -2,16 +2,17 @@ package id.co.anaheim.gateway.span.services;
import id.co.anaheim.gateway.span.models.JwtUsername; import id.co.anaheim.gateway.span.models.JwtUsername;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.asynchttpclient.AsyncHttpClient; import org.asynchttpclient.*;
import org.asynchttpclient.BoundRequestBuilder;
import org.asynchttpclient.Response;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.function.ServerRequest; import org.springframework.web.servlet.function.ServerRequest;
import org.springframework.web.servlet.function.ServerResponse; import org.springframework.web.servlet.function.ServerResponse;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import static org.asynchttpclient.Dsl.asyncHttpClient; import static org.asynchttpclient.Dsl.asyncHttpClient;
@ -20,12 +21,10 @@ import static org.asynchttpclient.Dsl.asyncHttpClient;
public class HttpClientService { public class HttpClientService {
private final String targetUrl; private final String targetUrl;
private final AsyncHttpClient asyncHttpClient;
private final JwtService jwtService; private final JwtService jwtService;
public HttpClientService(String targetUrl, JwtService jwtService) { public HttpClientService(String targetUrl, JwtService jwtService) {
this.targetUrl = targetUrl; this.targetUrl = targetUrl;
this.asyncHttpClient = asyncHttpClient();
this.jwtService = jwtService; this.jwtService = jwtService;
} }
@ -40,8 +39,13 @@ public class HttpClientService {
log.info("request body {}", body); log.info("request body {}", body);
log.info("request headers {}", request.headers()); log.info("request headers {}", request.headers());
log.info("request params {}", request.params()); log.info("request params {}", request.params());
try (AsyncHttpClient asyncHttpClient = asyncHttpClient()) {
BoundRequestBuilder boundRequestBuilder = asyncHttpClient BoundRequestBuilder boundRequestBuilder = asyncHttpClient
.prepare(request.method().toString(), url) .prepare(request.method().toString(), url)
//.setReadTimeout(Duration.ofMinutes(120))
//.setRequestTimeout(Duration.ofMinutes(120))
.setReadTimeout(Duration.ofMinutes(15))
.setRequestTimeout(Duration.ofMinutes(15))
.setBody(body) .setBody(body)
.addHeader("Content-Type", request.headers().header("Content-Type")); .addHeader("Content-Type", request.headers().header("Content-Type"));
if (!request.headers().header("token").isEmpty()) { if (!request.headers().header("token").isEmpty()) {
@ -72,6 +76,10 @@ public class HttpClientService {
return ServerResponse.status(response.getStatusCode()) return ServerResponse.status(response.getStatusCode())
.header("Content-Type", response.getContentType()) .header("Content-Type", response.getContentType())
.body(response.getResponseBody()); .body(response.getResponseBody());
} catch (IOException | ExecutionException | InterruptedException e) {
log.error("Http error", e);
}
} catch (Exception e) { } catch (Exception e) {
log.error("handleException - failed to run request again {}", url, e); log.error("handleException - failed to run request again {}", url, e);
} }

@ -1,15 +1,24 @@
server: server:
port: 8888 #prod port: 8888 #prod
#port: 8778 #dev #port: 8778 #dev
tomcat:
max-swallow-size: 8192MB
max-http-form-post-size: 8192MB
spring: spring:
datasource: datasource:
url: jdbc:oracle:thin:@//10.216.100.100:1521/pdbsoadev #url: jdbc:oracle:thin:@//10.216.100.100:1521/pdbsoauat
#url: jdbc:oracle:thin:@//10.216.100.100:1521/pdbsoadev
#url: jdbc:oracle:thin:@//soadb:1521/pdbsoauat
url: jdbc:oracle:thin:@//dbmsoascan.kemenkeu.go.id:1521/pdbsoaprod.kemenkeu.go.id
#url: jdbc:oracle:thin:@localhost:1521:oracle #url: jdbc:oracle:thin:@localhost:1521:oracle
username: gateway username: master_user
#username: gateway #username: gateway
password: welcome1 #username: gateway
password: m4sterPassw0rd1
#password: gateway #password: gateway
hikari:
schema: gateway
cloud: cloud:
gateway: gateway:
mvc: mvc:
@ -26,7 +35,9 @@ spring:
app: app:
gateway: gateway:
remote-servers: remote-servers:
span: http://10.216.99.101:8002 #span: https://esbuat-djpb.kemenkeu.go.id
span: https://esb-djpb.kemenkeu.go.id
#span: http://10.216.99.101:8002
#span: https://672fbf9066e42ceaf15e9a9b.mockapi.io #span: https://672fbf9066e42ceaf15e9a9b.mockapi.io
users: http://localhost:8989 users: http://localhost:8989
#users: http://localhost:8779 #users: http://localhost:8779