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