perbaikan jika static token tidak ada
This commit is contained in:
parent
b925d10f57
commit
e927687e59
@ -51,8 +51,10 @@ public class HttpClientService {
|
||||
String authorizationHeader = request.headers().header("Authorization").get(0);
|
||||
String token = authorizationHeader.substring(7);
|
||||
String staticToken = jwtService.extractStaticToken(token);
|
||||
if (!staticToken.equals("admin")) {
|
||||
boundRequestBuilder.addHeader("token", staticToken);
|
||||
}
|
||||
}
|
||||
Future<Response> whenResponse = boundRequestBuilder
|
||||
.execute();
|
||||
log.info("request {} {}", request.method(), url);
|
||||
|
||||
@ -50,11 +50,16 @@ public class JwtService {
|
||||
String responseBody = response.getResponseBody();
|
||||
Gson gson = new Gson();
|
||||
StaticToken staticToken = gson.fromJson(responseBody, StaticToken.class);
|
||||
if (staticToken != null) {
|
||||
claims.put("token", staticToken.getToken());
|
||||
} else {
|
||||
claims.put("token", "admin");
|
||||
}
|
||||
} catch (IOException | ExecutionException | InterruptedException e) {
|
||||
claims.put("token", "admin");
|
||||
log.error("error get token", e);
|
||||
}
|
||||
|
||||
log.info("here");
|
||||
return createToken(claims, user.getUsername());
|
||||
}
|
||||
|
||||
|
||||
@ -4,12 +4,12 @@ server:
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
#url: jdbc:oracle:thin:@//10.216.100.100:1521/pdbsoadev
|
||||
url: jdbc:oracle:thin:@localhost:1521:oracle
|
||||
#username: gateway
|
||||
url: jdbc:oracle:thin:@//10.216.100.100:1521/pdbsoadev
|
||||
#url: jdbc:oracle:thin:@localhost:1521:oracle
|
||||
username: gateway
|
||||
#password: welcome1
|
||||
password: gateway
|
||||
#username: gateway
|
||||
password: welcome1
|
||||
#password: gateway
|
||||
cloud:
|
||||
gateway:
|
||||
mvc:
|
||||
@ -26,8 +26,8 @@ spring:
|
||||
app:
|
||||
gateway:
|
||||
remote-servers:
|
||||
#pan: http://10.216.99.101:8002
|
||||
span: https://672fbf9066e42ceaf15e9a9b.mockapi.io
|
||||
span: http://10.216.99.101:8002
|
||||
#span: https://672fbf9066e42ceaf15e9a9b.mockapi.io
|
||||
users: http://localhost:8989
|
||||
#users: http://localhost:8779
|
||||
token: http://localhost:8787
|
||||
|
||||
Loading…
Reference in New Issue
Block a user