update
This commit is contained in:
parent
39e4887b0a
commit
f23c20d82b
@ -6,7 +6,7 @@ plugins {
|
||||
|
||||
group = 'id.co.anaheim'
|
||||
//version = '0.0.5-SNAPSHOT'
|
||||
version = '0.0.6'
|
||||
version = '0.0.13-Prod'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
@ -29,7 +29,6 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
@ -45,7 +44,7 @@ dependencies {
|
||||
implementation 'io.azam.ulidj:ulidj:1.0.4'
|
||||
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'
|
||||
runtimeOnly 'com.oracle.database.jdbc:ojdbc11'
|
||||
|
||||
BIN
cert/esbuat-djpbdomain.der
Normal file
BIN
cert/esbuat-djpbdomain.der
Normal file
Binary file not shown.
@ -50,7 +50,7 @@ public class JwtAuthFilter extends OncePerRequestFilter {
|
||||
} else {
|
||||
BasicResponse basicResponse = new BasicResponse();
|
||||
basicResponse.setFileName("");
|
||||
basicResponse.setResultCode("403");
|
||||
basicResponse.setResultCode("401");
|
||||
Gson gson = new Gson();
|
||||
if (authHeader != null && authHeader.startsWith("Bearer ")) {
|
||||
String token = authHeader.substring(7);
|
||||
|
||||
@ -32,7 +32,7 @@ public class AuthController {
|
||||
|
||||
User user = repository.findByUsername(authDto.getUsername());
|
||||
if (user == null) {
|
||||
response.setResultCode("403");
|
||||
response.setResultCode("401");
|
||||
response.setResultStatus("Tidak Memiliki Otorisasi");
|
||||
description.setMessage("Username/Password tidak sesuai");
|
||||
} else {
|
||||
@ -48,7 +48,7 @@ public class AuthController {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
description.setTokenExpiration(dateFormat.format(jwtExpiration.getValue()));
|
||||
} else {
|
||||
response.setResultCode("403");
|
||||
response.setResultCode("401");
|
||||
response.setResultStatus("Tidak Memiliki Otorisasi");
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.asynchttpclient.AsyncHttpClient;
|
||||
import org.asynchttpclient.BoundRequestBuilder;
|
||||
import org.asynchttpclient.Response;
|
||||
import org.asynchttpclient.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.servlet.function.ServerRequest;
|
||||
import org.springframework.web.servlet.function.ServerResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import static org.asynchttpclient.Dsl.asyncHttpClient;
|
||||
@ -20,12 +21,10 @@ import static org.asynchttpclient.Dsl.asyncHttpClient;
|
||||
public class HttpClientService {
|
||||
private final String targetUrl;
|
||||
|
||||
private final AsyncHttpClient asyncHttpClient;
|
||||
private final JwtService jwtService;
|
||||
|
||||
public HttpClientService(String targetUrl, JwtService jwtService) {
|
||||
this.targetUrl = targetUrl;
|
||||
this.asyncHttpClient = asyncHttpClient();
|
||||
this.jwtService = jwtService;
|
||||
}
|
||||
|
||||
@ -40,38 +39,47 @@ public class HttpClientService {
|
||||
log.info("request body {}", body);
|
||||
log.info("request headers {}", request.headers());
|
||||
log.info("request params {}", request.params());
|
||||
BoundRequestBuilder boundRequestBuilder = asyncHttpClient
|
||||
.prepare(request.method().toString(), url)
|
||||
.setBody(body)
|
||||
.addHeader("Content-Type", request.headers().header("Content-Type"));
|
||||
if (!request.headers().header("token").isEmpty()) {
|
||||
List<String> token = request.headers().header("token");
|
||||
boundRequestBuilder.addHeader("token", token);
|
||||
}
|
||||
if (!request.headers().header("Authorization").isEmpty()) {
|
||||
String authorizationHeader = request.headers().header("Authorization").get(0);
|
||||
String token = authorizationHeader.substring(7);
|
||||
JwtUsername username = jwtService.extractUsername(token);
|
||||
if (username.isValid() && !username.getValue().equals("admin")) {
|
||||
String staticToken = jwtService.extractStaticToken(token);
|
||||
if (staticToken != null) {
|
||||
boundRequestBuilder.addHeader("token", staticToken);
|
||||
}
|
||||
try (AsyncHttpClient asyncHttpClient = asyncHttpClient()) {
|
||||
BoundRequestBuilder boundRequestBuilder = asyncHttpClient
|
||||
.prepare(request.method().toString(), url)
|
||||
//.setReadTimeout(Duration.ofMinutes(120))
|
||||
//.setRequestTimeout(Duration.ofMinutes(120))
|
||||
.setReadTimeout(Duration.ofMinutes(15))
|
||||
.setRequestTimeout(Duration.ofMinutes(15))
|
||||
.setBody(body)
|
||||
.addHeader("Content-Type", request.headers().header("Content-Type"));
|
||||
if (!request.headers().header("token").isEmpty()) {
|
||||
List<String> token = request.headers().header("token");
|
||||
boundRequestBuilder.addHeader("token", token);
|
||||
}
|
||||
if (!request.headers().header("Authorization").isEmpty()) {
|
||||
String authorizationHeader = request.headers().header("Authorization").get(0);
|
||||
String token = authorizationHeader.substring(7);
|
||||
JwtUsername username = jwtService.extractUsername(token);
|
||||
if (username.isValid() && !username.getValue().equals("admin")) {
|
||||
String staticToken = jwtService.extractStaticToken(token);
|
||||
if (staticToken != null) {
|
||||
boundRequestBuilder.addHeader("token", staticToken);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Future<Response> whenResponse = boundRequestBuilder
|
||||
.execute();
|
||||
log.info("request {} {}", request.method(), url);
|
||||
log.info("request headers {}", request.headers());
|
||||
|
||||
Response response = whenResponse.get();
|
||||
log.info("Response {}", response);
|
||||
log.info("Response Body {}", response.getResponseBody());
|
||||
log.info("Response Content Type {} ", response.getContentType());
|
||||
return ServerResponse.status(response.getStatusCode())
|
||||
.header("Content-Type", response.getContentType())
|
||||
.body(response.getResponseBody());
|
||||
} catch (IOException | ExecutionException | InterruptedException e) {
|
||||
log.error("Http error", e);
|
||||
}
|
||||
Future<Response> whenResponse = boundRequestBuilder
|
||||
.execute();
|
||||
log.info("request {} {}", request.method(), url);
|
||||
log.info("request headers {}", request.headers());
|
||||
|
||||
Response response = whenResponse.get();
|
||||
log.info("Response {}", response);
|
||||
log.info("Response Body {}", response.getResponseBody());
|
||||
log.info("Response Content Type {} ", response.getContentType());
|
||||
return ServerResponse.status(response.getStatusCode())
|
||||
.header("Content-Type", response.getContentType())
|
||||
.body(response.getResponseBody());
|
||||
} catch (Exception e) {
|
||||
log.error("handleException - failed to run request again {}", url, e);
|
||||
}
|
||||
|
||||
@ -1,15 +1,24 @@
|
||||
server:
|
||||
port: 8888 #prod
|
||||
#port: 8778 #dev
|
||||
tomcat:
|
||||
max-swallow-size: 8192MB
|
||||
max-http-form-post-size: 8192MB
|
||||
|
||||
spring:
|
||||
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
|
||||
username: gateway
|
||||
username: master_user
|
||||
#username: gateway
|
||||
password: welcome1
|
||||
#username: gateway
|
||||
password: m4sterPassw0rd1
|
||||
#password: gateway
|
||||
hikari:
|
||||
schema: gateway
|
||||
cloud:
|
||||
gateway:
|
||||
mvc:
|
||||
@ -26,7 +35,9 @@ spring:
|
||||
app:
|
||||
gateway:
|
||||
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
|
||||
users: http://localhost:8989
|
||||
#users: http://localhost:8779
|
||||
|
||||
Loading…
Reference in New Issue
Block a user