[management] Record source IP and location on dashboard login events

Merged
ML
1d ago
+304-5

Describe your changes

Dashboard login events carry only a timestamp, so admins cannot tell where a login came from.

The auth middleware now resolves the client IP with the configured TrustedHTTPProxies (X-Forwarded-For is honoured only when the request comes from a trusted proxy) and passes it on the request context. The MCP OAuth callback does the same with its trusted proxies. On a new login, the dashboard.login event stores location_connection_ip and, when geolocation resolves the address, country, city and geo name ID, using the same keys as peer login events. A failed or empty lookup keeps the IP and leaves the location out.

Deployments behind a reverse proxy that is not listed in TrustedHTTPProxies record the proxy's IP.

Split out of netbirdio/netbird#8620.

Issue ticket number and link

No issue yet.

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • I ran and tested this change locally — I did not rely on CI to find out whether it works
  • This PR has a single purpose (not a fix + refactor + feature in one)
  • This change is a trivial fix, OR it links an issue the NetBird team agreed on beforehand. Changes to the public API, gRPC protocols, functionality behavior, CLI / service flags, or new features always need that agreement first. See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/1118

Summary by CodeRabbit

  • New Features
    • Dashboard login events now include the client IP address when available, along with country and city details when geolocation lookup succeeds.
    • Client IP detection during authentication and identity-provider sign-in now accounts for configured trusted proxies.