JanssenProject / JanssenProject/jans
fix(jans-fido2): metrics API omits ipAddress (and userAgent/deviceInfo) from responses
@imran-ishaq is already working on this.
Since Jul 2, 2026.
- Dominant language
- Java
- Stars
- 648
- Forks
- 174
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 110
Description
**Describe the bug**
The FIDO2 Metrics API does not return the `ipAddress` field in its responses, even though the field is declared in the OpenAPI spec (`jans-fido2/docs/jansFido2Swagger.yaml`). The same problem affects `userAgent` and `deviceInfo`.
Root cause: In `MetricService`, metric events are recorded inside `CompletableFuture.runAsync(...)`, and the client IP, User-Agent and device info are read there from the injected `@Context HttpServletRequest`. That proxy is bound to the request-handling thread, so on the async ForkJoinPool thread the reads (`request.getRemoteAddr()` / `request.getHeader(...)`) throw. The exception is swallowed by the surrounding `try/catch`, leaving `ipAddress`/`userAgent`/`deviceInfo` null. Because `Fido2MetricsEntry` uses `@JsonInclude(NON_NULL)`, the null fields are dropped from the serialized response.
**To Reproduce**
Steps to reproduce the behavior:
1. Enable FIDO2 metrics (`fido2MetricsEnabled` and `fido2DeviceInfoCollection`).
2. Perform a passkey registration or authentication so a metric entry is stored.
3. Call `GET /jans-fido2/restv1/metrics/entries?startTime=...&endTime=...`.
4. Observe that the returned entries have no `ipAddress` (nor `userAgent`/`deviceInfo`) field, despite the OpenAPI spec listing it.
**Expected behavior**
The metric entries returned by `/metrics/entries` should include the `ipAddress` (and `userAgent`/`deviceInfo`) captured from the originating HTTP request, as documented in the OpenAPI spec.
**Screenshots**
N/A — backend API response issue.
**Desktop (please complete the following information):**
- OS: N/A (server-side)
- Browser: N/A
- Version: 0.0.0-nightly
**Smartphone (please complete the following information):**
- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A
**Additional context**
Affected file: `jans-fido2/server/src/main/java/io/jans/fido2/service/shared/MetricService.java`.
Fix: Capture request-derived data (IP, User-Agent, device info) synchronously on the request thread — before dispatching the async task — via a new `extractRequestData()` helper, and thread an immutable `RequestData` holder through `recordDetailedMetrics`/`createMetricsData` instead of passing the thread-bound `HttpServletRequest` proxy into the background task.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.