Reputation: 1
I have a JHipster API Gateway where Swagger (http://localhost:8080/admin/api-docs
) does not display the endpoints of other microservices after upgrading to Spring Boot 3.3.5.
After upgrading to Spring Boot 3.3.5 (which includes WebFlux 6.1.14), the issue appears. However, in Spring Boot 3.3.4 (WebFlux 6.1.13), everything works fine.
ModifyServersOpenApiFilter
is supposed to intercept API docs requests, but logs indicate it is not being executed in 3.3.5.JwtDecoder
) is never invoked when debugging in 3.3.5, but it works fine in 3.3.4.api-docs
requests, meaning security might be blocking the API documentation retrieval.This should intercept and modify API Docs responses:
public class ModifyServersOpenApiFilter implements GlobalFilter, Ordered {
private static final String OPEN_API_PATH = "/v3/api-docs";
private static final Logger log = LoggerFactory.getLogger(ModifyServersOpenApiFilter.class);
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
String path = exchange.getRequest().getURI().getRawPath();
log.info("DEBUG PATH in ModifyServersOpenApiFilter: {}", path);
if (path.startsWith("/services") && path.contains(OPEN_API_PATH)) {
ServerHttpResponse originalResponse = exchange.getResponse();
DataBufferFactory bufferFactory = originalResponse.bufferFactory();
ServerHttpResponseDecorator decoratedResponse = createModifyServersOpenApiInterceptor(path, originalResponse, bufferFactory);
log.info("AUTH HEADER: {}", exchange.getRequest().getHeaders().get("Authorization"));
return chain.filter(exchange.mutate().response(decoratedResponse).build());
} else {
log.info("AUTH HEADER: {}", exchange.getRequest().getHeaders().get("Authorization"));
return chain.filter(exchange);
}
}
}
This is the JWT Decoder that works in Spring Boot 3.3.4 but is never executed in 3.3.5:
@Bean
JwtDecoder jwtDecoder() {
NimbusJwtDecoder jwtDecoder = JwtDecoders.fromOidcIssuerLocation(issuerUri);
OAuth2TokenValidator<Jwt> audienceValidator = new AudienceValidator(jHipsterProperties.getSecurity().getOauth2().getAudience());
OAuth2TokenValidator<Jwt> withIssuer = JwtValidators.createDefaultWithIssuer(issuerUri);
OAuth2TokenValidator<Jwt> withAudience = new DelegatingOAuth2TokenValidator<>(withIssuer, audienceValidator);
jwtDecoder.setJwtValidator(withAudience);
return jwtDecoder;
}
The behavior in Spring Boot 3.3.5 is similar to this reported issue.
It seems that the upgrade may have introduced a blocking thread issue with WebFlux that prevents API documentation requests from being properly processed.
Is there a known issue with Spring Boot 3.3.5 + WebFlux 6.1.14 that affects JHipster Gateway's ability to retrieve API Docs?
Could this be related to security filters or JWT authentication blocking requests?
Any workaround for this issue, other than downgrading to Spring Boot 3.3.4?
Swagger should display all microservice endpoints correctly in the API Gateway (/admin/api-docs
). JWT authentication should function as expected, allowing secure access to API documentation.
In Spring Boot 3.3.4, logs show successful service discovery, authentication, and secured requests:
2025-02-28T16:31:40.023+03:00 INFO 15948 --- [foReplicator-%d] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1740749500023, current=UP, previous=DOWN]
2025-02-28T16:31:40.023+03:00 INFO 15948 --- [foReplicator-%d] com.netflix.discovery.DiscoveryClient : DiscoveryClient_WORKFLOW SERVICE/workflow service:bfd4a39b6c2133c10ff13f994de905ca: registering service...
2025-02-28T16:31:40.039+03:00 INFO 15948 --- [foReplicator-%d] com.netflix.discovery.DiscoveryClient : DiscoveryClient_WORKFLOW SERVICE/workflow service:bfd4a39b6c2133c10ff13f994de905ca - registration status: 204
2025-02-28T16:32:00.002+03:00 INFO 15948 --- [ce-scheduling-1] c.s.w.s.workflow.WorkflowManagerService : Lifetime check is running for the priority queue items..
2025-02-28T16:32:00.018+03:00 INFO 15948 --- [ce-scheduling-1] c.s.w.s.workflow.WorkflowManagerService : Found 0 priority queue items to stop.
2025-02-28T16:32:37.640+03:00 DEBUG 15948 --- [ XNIO-1 task-2] o.s.security.web.FilterChainProxy : Securing GET /management/jhiopenapigroups
2025-02-28T16:32:40.187+03:00 DEBUG 15948 --- [ XNIO-1 task-2] o.s.s.o.s.r.a.JwtAuthenticationProvider : Authenticated token
2025-02-28T16:32:40.189+03:00 DEBUG 15948 --- [ XNIO-1 task-2] .s.r.w.a.BearerTokenAuthenticationFilter : Set SecurityContextHolder to JwtAuthenticationToken [Principal=org.springframework.security.oauth2.jwt.Jwt@546d2b41, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=192.168.1.23, SessionId=null], Granted Authorities=[ROLE_ADMIN]]
2025-02-28T16:32:40.199+03:00 DEBUG 15948 --- [ XNIO-1 task-2] o.s.security.web.FilterChainProxy : Secured GET /management/jhiopenapigroups
2025-02-28T16:33:00.005+03:00 INFO 15948 --- [ce-scheduling-2] c.s.w.s.workflow.WorkflowManagerService : Lifetime check is running for the priority queue items..
2025-02-28T16:33:00.008+03:00 INFO 15948 --- [ce-scheduling-2] c.s.w.s.workflow.WorkflowManagerService : Found 0 priority queue items to stop.
2025-02-28T16:34:00.002+03:00 INFO 15948 --- [ce-scheduling-2] c.s.w.s.workflow.WorkflowManagerService : Lifetime check is running for the priority queue items..
2025-02-28T16:34:00.007+03:00 INFO 15948 --- [ce-scheduling-2] c.s.w.s.workflow.WorkflowManagerService : Found 0 priority queue items to stop.
2025-02-28T16:34:01.645+03:00 DEBUG 15948 --- [ XNIO-1 task-2] o.s.security.web.FilterChainProxy : Securing GET /v3/api-docs/springdocDefault
2025-02-28T16:34:03.943+03:00 DEBUG 15948 --- [ XNIO-1 task-2] o.s.s.o.s.r.a.JwtAuthenticationProvider : Authenticated token
2025-02-28T16:34:03.944+03:00 DEBUG 15948 --- [ XNIO-1 task-2] .s.r.w.a.BearerTokenAuthenticationFilter : Set SecurityContextHolder to JwtAuthenticationToken [Principal=org.springframework.security.oauth2.jwt.Jwt@546d2b41, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=192.168.1.23, SessionId=null], Granted Authorities=[ROLE_ADMIN]]
2025-02-28T16:34:03.946+03:00 DEBUG 15948 --- [ XNIO-1 task-2] o.s.security.web.FilterChainProxy : Secured GET /v3/api-docs/springdocDefault
2025-02-28T16:34:04.533+03:00 INFO 15948 --- [ XNIO-1 task-2] o.springdoc.api.AbstractOpenApiResource : Init duration for springdoc-openapi is: 572 ms
Upvotes: 0
Views: 21