Skip to content

fix(jans-fido2): capture request IP/User-Agent on request thread for …#14481

Open
imran-ishaq wants to merge 1 commit into
mainfrom
fix-jans-fido2-metrics-missing-ipaddress
Open

fix(jans-fido2): capture request IP/User-Agent on request thread for …#14481
imran-ishaq wants to merge 1 commit into
mainfrom
fix-jans-fido2-metrics-missing-ipaddress

Conversation

@imran-ishaq

@imran-ishaq imran-ishaq commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

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.

Target issue

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.

closes #14480

Implementation Details


Test and Document the changes

  • Static code analysis has been run locally and issues have been fixed
  • Relevant unit and integration tests have been added/updated
  • Relevant documentation has been updated if any (i.e. user guides, installation and configuration guides, technical design docs etc)

Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with docs: to indicate documentation changes or if the below checklist is not selected.

  • I confirm that there is no impact on the docs due to the code changes in this PR.

…metrics

Signed-off-by: imran <imranishaq7071@gmail.com>
@imran-ishaq
imran-ishaq marked this pull request as ready for review July 2, 2026 11:48
@imran-ishaq
imran-ishaq requested a review from yurem as a code owner July 2, 2026 11:48
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ad92e499-026f-4973-8fe5-0d505032c789

📥 Commits

Reviewing files that changed from the base of the PR and between 68c3d94 and 564dc85.

📒 Files selected for processing (1)
  • jans-fido2/server/src/main/java/io/jans/fido2/service/shared/MetricService.java
👮 Files not reviewed due to content moderation or server errors (1)
  • jans-fido2/server/src/main/java/io/jans/fido2/service/shared/MetricService.java

📝 Walkthrough

[!WARNING]

Walkthrough skipped

File diffs could not be summarized.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-jans-fido2-metrics-missing-ipaddress

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mo-auto

mo-auto commented Jul 2, 2026

Copy link
Copy Markdown
Member

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@mo-auto mo-auto added comp-jans-fido2 Component affected by issue or PR kind-bug Issue or PR is a bug in existing functionality labels Jul 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-jans-fido2 Component affected by issue or PR kind-bug Issue or PR is a bug in existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(jans-fido2): metrics API omits ipAddress (and userAgent/deviceInfo) from responses

2 participants