Skip to content

feat: automatic portal login after connecting - #34

Merged
CallMeTechie merged 1 commit into
mainfrom
callmetechie/determined-knuth-awmcxl
Oct 6, 2026
Merged

CallMeTechie merged 1 commit into
mainfrom
callmetechie/determined-knuth-awmcxl

Conversation

@CallMeTechie

Copy link
Copy Markdown
Owner

Summary

Opening the portal now logs the user in automatically through a one-time link.

  • New POST /api/v1/client/portal-link endpoint (ApiClient.requestPortalLink) plus the ApiClient.getPortalLink(portalUrl) suspend extension. It returns the link or null, and never throws.
  • getPortalLink returns null on any of these: a non-2xx status, a network error or malformed body, no answer within 5 s, a missing url, or a url whose scheme or host differs from the configured portalUrl.
  • VpnViewModel.openPortal (button) and the new autoOpenPortalIfNeeded (auto-open after connect) fetch a fresh link right before opening. The fetch runs in viewModelScope and the browser starts on the main thread. If the fetch fails, the plain portalUrl opens as before. A second tap while a fetch is running is ignored.
  • The once-per-tunnel-session gate (keyed on connectedSince) moved from VpnScreen into the ViewModel so it can be tested.
  • The link is never cached, stored or logged. Log lines name only the failure class, and PortalLinkResponse.toString() masks the URL.

Tests

  • PortalLinkTest (MockWebServer) covers success (POST to the right path), 404, 500, timeout, network error, missing url, malformed body, host mismatch, scheme mismatch and the same-origin rules. It also checks that neither the link nor the ticket shows up in Timber or HTTP (HEADERS level) logs.
  • VpnViewModelTest covers opening the link, a fresh fetch on every tap, fallback on 404, the 5 s timeout, host mismatch and network errors, ignoring a double tap, auto-open hitting the endpoint once per session (and again for a new session), and no auto-open when it is disabled or the tunnel is not connected.
  • ./gradlew test lintRelease passes locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_016xX1efcZF1f6G9rhmaJNLD


Generated by Claude Code

Opening the portal (automatically after connect and via the button) now
fetches a fresh one-time login link from POST /api/v1/client/portal-link
right before opening it. On a non-2xx status, network error, timeout
over 5 s, missing url or a url whose scheme/host differs from the
configured portal URL, the plain portal URL is opened as before.

The link carries a single-use ticket: it is never cached, stored or
logged. The once-per-session auto-open gate moved into the ViewModel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016xX1efcZF1f6G9rhmaJNLD
@CallMeTechie
CallMeTechie merged commit bb97814 into main Oct 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants