Skip to content

Let the phones sign in: a code may go to the app's own scheme - #49

Merged
tiendc merged 1 commit into
mainfrom
device/app-redirect
Dec 5, 2026
Merged

tiendc merged 1 commit into
mainfrom
device/app-redirect

Conversation

@tiendc

@tiendc tiendc commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

The shellwing app's phones can now sign in to a server. The desktop app gets its code on a loopback port (http://127.0.0.1:<port>/callback). A phone cannot listen on a port while its browser sheet (iOS) or Custom Tab (Android) is open, so the browser goes back to the app's own scheme instead (RFC 8252, 7.1).

What changes

  • validDeviceRedirect accepts exactly com.hivepaas.shellwing://server, as well as a literal loopback address.
  • Other values on the same scheme are refused: another host, a trailing slash, a query, or a different case. The tests list them.
  • Another app that claimed the scheme could catch a code, but it could not exchange the code: PKCE keeps the verifier on the phone.
  • The approval page (/connect-device/) shows a phone icon when the platform is ios or android.
  • The error comment and the API description now mention the phones.

Tests

  • go test ./usecase/sessionuc/ covers the redirect cases.
  • tsc, eslint and prettier pass on the page.
  • End to end: the app's new a_phone_signs_in_through_the_apps_scheme test ran against this branch's server on a fresh database. It checks that a phone signs in through the scheme, reads and writes, and is listed with platform ios. After signing out, its token stops working. A redirect to a web address is answered 400.
  • Tried by hand: the phones' sign-in on the iOS Simulator and an Android emulator, against this branch's server.

The app's side is a separate PR in hivepaas/shellwing. This PR has to be deployed before the phones can sign in to a real server.

Unrelated: the app's older e2e test, two_devices_share_a_vault_and_one_is_given_a_certificate, now fails against main with ERR_SSH_SELF_GRANT. The admin grants itself an account, which the server now refuses.

🤖 Generated with Claude Code

The desktop app gets its code on a loopback port. The phones cannot listen
on one while the browser sheet (iOS) or Custom Tab (Android) is open, so
they come back to the app's own scheme instead (RFC 8252, 7.1). The server
now takes exactly com.hivepaas.shellwing://server besides a loopback port.
Another app that claimed the scheme could catch a code, but not use it
without the verifier, which stays on the phone.

The approval page shows a phone for ios and android.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tiendc
tiendc merged commit 488817b into main Dec 5, 2026
4 of 6 checks passed
@tiendc
tiendc deleted the device/app-redirect branch December 5, 2026 07:54
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.

1 participant