Spring MTL безопасности между микросервисами с использованием PCF и передать недавно обновленный сертификат - PullRequest
0 голосов
/ 10 января 2020

Я использую PCF, PAS и https://github.com/cloudfoundry/java-buildpack-security-provider.
Есть ли java пример того, как использовать его для достижения MTL между моими микроуслугами?

Например:

мой микросервис вызывает другой микросервис

@GetMapping("/getCaseList")
@PreAuthorize("hasAnyAuthority('Employer.GetEmployer')")
public ResponseEntity getCaseList(@RequestParam(required = false) String officerEmail) {
    HttpEntity<Object> requestEntity = new HttpEntity<>(null, authUtils.getNonRelayAuthHeaders());
    try{
    ResponseEntity response = restTemplate.exchange("https://casemangement/getCaseList?officerEmail=someofficer@gmail.com",
            HttpMethod.GET, requestEntity, Object.class);
    return new ResponseEntity(response.getBody(), authUtils.getResponseHeaders(response), response.getStatusCode());
    } catch (HttpClientErrorException e){
        return new ResponseEntity(e.getMessage(), e.getStatusCode());
    }
}

Мой принимающий вызов микросервиса

@GetMapping("/getCaseList")
public ResponseEntity getCaseList(Principal principal, @RequestParam(required = false) String officerEmail) {
    String applicationId = principal.getName();
    String certificateSerialNumber = this.serialNumberExtractor.getSerialNumber(principal);

    System.out.println(String.format("You authenticated using x509 certificate for %s with SN %s", applicationId, certificateSerialNumber));
    return new ResponseEntity(caseService.getCaseList(officerEmail), HttpStatus.OK);
}

Как использовать вышеизложенное для установления соединения MTL?

...