Skip to content

Commit

Permalink
fix: remove Insertion of sensitive information into log files; add lo…
Browse files Browse the repository at this point in the history
…gging the status code and url on error
  • Loading branch information
dvasunin committed Apr 23, 2024
1 parent fdfaed4 commit a1c75d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public ErrorDecoder getErrorDecoder(ObjectMapper mapper) {
.getOrElse(responseStr);
var statusCode = HttpStatusCode.valueOf(response.status());
log.error("Error in Feign client: {}", msg);
log.error("Status code: {}", statusCode);
log.error("URL: {}", response.request().url());
if (response.request().body() != null) {
log.error("Original payload: {}", new String(response.request().body(), response.request().charset()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.selfdescriptionfactory.config.TechnicalUsersDetails;
import org.eclipse.tractusx.selfdescriptionfactory.service.keycloak.KeycloakManager;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.core.env.Environment;
Expand All @@ -41,7 +40,6 @@
@RequiredArgsConstructor
public class ClearingHouse implements InitializingBean {

private final KeycloakManager keycloakManager;
private final TechnicalUsersDetails technicalUsersDetails;
private final ClearingHouseClient clearingHouseClient;
private final ObjectMapper objectMapper = new ObjectMapper();
Expand All @@ -60,7 +58,6 @@ protected void debug(VerifiableCredential payload, String externalId) {
var annotation = ClearingHouseClient.class.getAnnotation(FeignClient.class);
var name = annotation.name();
Optional.ofNullable(technicalUsersDetails.getUsersDetails().get(name)).map(TechnicalUsersDetails.UserDetail::uri).ifPresent(uri -> log.debug("URL: {}", uri));
Optional.of(name).map(keycloakManager::getToken).ifPresent(token -> log.debug("Authorization: {}", token));
log.debug("ExternalId: {}", externalId);
log.debug("payload: {}", objectMapper.writeValueAsString(payload));
}
Expand Down

0 comments on commit a1c75d5

Please sign in to comment.