You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently, while using JHipster to build a microservice application, I encountered an issue with pagination APIs.
Since the pagination API in microservices follows RFC 5988 (Web Linking), when we call a paginated API through the gateway, we can see headers in the API response similar to the following:
http://localhost:9000/services/store/api/products?page=0&size=20&sort=id,asc&cacheBuster=1724983079122
HTTP/1.1 200 OK
...
link: <http://localhost:9000/api/products?sort=id%2Casc&cacheBuster=1724983079122&page=0&size=20>; rel="last",<http://localhost:9000/api/products?sort=id%2Casc&cacheBuster=1724983079122&page=0&size=20>; rel="first"
...
However, it's clear that the value in the Link header is incorrect. The microservice should dynamically adjust the response based on the X-Forwarded-Prefix header forwarded by the gateway, such as:
This issue only affects the URL display in the response Link header, so it's not a critical error as it doesn't break the core functionality. However, the potential problem arises when a client application accesses the paginated API through the API Gateway and relies on the Link header for navigation. In that case, the incorrect URLs in the Link header would lead to issues with paginated requests.
Thank you for your response! I’ve submitted a PR addressing the issue we discussed. I wanted to mention that, based on my understanding, using forwarded headers may introduce potential security concerns. Given this, I’m uncertain whether the current approach is the best solution.
I would appreciate your thoughts on this matter, especially considering the security implications.
Overview of the issue
Recently, while using JHipster to build a microservice application, I encountered an issue with pagination APIs.
Since the pagination API in microservices follows RFC 5988 (Web Linking), when we call a paginated API through the gateway, we can see headers in the API response similar to the following:
However, it's clear that the value in the Link header is incorrect. The microservice should dynamically adjust the response based on the
X-Forwarded-Prefix
header forwarded by the gateway, such as:Motivation for or Use Case
This issue is problematic because the microservices should respect the gateway’s forwarded headers when constructing the pagination links.
Reproduce the error
X-Forwarded-Prefix
.Related issues
A similar issue is #26521, but it discusses security concerns with Forwarded headers.
Suggest a Fix
According to the official Spring documentation, we can resolve this by:
ForwardedHeaderFilter
.ForwardedHeaderTransformer
.server.forward-headers-strategy
toFRAMEWORK
.Is there a better solution to handle this situation while considering the security implications?
JHipster Version(s)
JHipster version: latest
JHipster configuration
JDL:
Browsers and Operating System
The text was updated successfully, but these errors were encountered: