mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Include security error body in WebFlux Cloud Foundry endpoint responses
See gh-50256 Signed-off-by: htjworld <itjhan01@gmail.com>
This commit is contained in:
+2
-2
@@ -109,7 +109,7 @@ class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointH
|
||||
return CloudFoundryWebFluxEndpointHandlerMapping.this.securityInterceptor.preHandle(exchange, "")
|
||||
.map((securityResponse) -> {
|
||||
if (!securityResponse.getStatus().equals(HttpStatus.OK)) {
|
||||
return new ResponseEntity<>(securityResponse.getStatus());
|
||||
return new ResponseEntity<>(securityResponse.getMessage(), securityResponse.getStatus());
|
||||
}
|
||||
AccessLevel accessLevel = exchange.getAttribute(AccessLevel.REQUEST_ATTRIBUTE);
|
||||
String requestUri = UriComponentsBuilder.fromUri(request.getURI()).replaceQuery(null).toUriString();
|
||||
@@ -164,7 +164,7 @@ class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointH
|
||||
private Mono<ResponseEntity<Object>> flatMapResponse(ServerWebExchange exchange,
|
||||
@Nullable Map<String, String> body, SecurityResponse securityResponse) {
|
||||
if (!securityResponse.getStatus().equals(HttpStatus.OK)) {
|
||||
return Mono.just(new ResponseEntity<>(securityResponse.getStatus()));
|
||||
return Mono.just(new ResponseEntity<>(securityResponse.getMessage(), securityResponse.getStatus()));
|
||||
}
|
||||
return this.delegate.handle(exchange, body);
|
||||
}
|
||||
|
||||
+6
-2
@@ -100,7 +100,9 @@ class CloudFoundryWebFluxEndpointIntegrationTests {
|
||||
.header("Authorization", "bearer " + mockAccessToken())
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.isEqualTo(HttpStatus.FORBIDDEN)));
|
||||
.isEqualTo(HttpStatus.FORBIDDEN)
|
||||
.expectBody(String.class)
|
||||
.isEqualTo("{\"security_error\":\"Access denied\"}")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,7 +181,9 @@ class CloudFoundryWebFluxEndpointIntegrationTests {
|
||||
.header("Authorization", "bearer " + mockAccessToken())
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.isUnauthorized()));
|
||||
.isUnauthorized()
|
||||
.expectBody(String.class)
|
||||
.isEqualTo("{\"security_error\":\"invalid-token\"}")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user