Store per-device user agent for remoteStorage authorizations #257

Merged
raucao merged 13 commits from feature/rs_device_tokens into feature/rs_auth_pkce 2026-11-03 16:39:11 +00:00
Owner

Second of three PRs for #254. Stacked on #256 (PKCE core) — please review/merge that first.

What

  • Adds a user_agent column to remote_storage_authorizations and rs_authorization_codes, captured at consent, carried on the authorization code, and stored on the authorization at exchange (and directly for the implicit flow).
  • The storage dashboard (#258) uses this to label connected devices.

Because the existing-token reuse shortcut was removed in #256, every authorization is already a distinct per-device token.

Storage-first

Documents the storage-first launch (remoteStorage spec section 11) with an explicit spec: launch_app hands the app only #remotestorage=<address>, never an access token. The app then runs the application-first (now PKCE-capable) flow itself.

Tests

bundle exec rspec — 350 examples, 0 failures.

Part of #254.

Second of three PRs for #254. Stacked on #256 (PKCE core) — please review/merge that first. ## What - Adds a `user_agent` column to `remote_storage_authorizations` and `rs_authorization_codes`, captured at consent, carried on the authorization code, and stored on the authorization at exchange (and directly for the implicit flow). - The storage dashboard (#258) uses this to label connected devices. Because the existing-token reuse shortcut was removed in #256, every authorization is already a distinct per-device token. ## Storage-first Documents the storage-first launch (remoteStorage spec section 11) with an explicit spec: `launch_app` hands the app only `#remotestorage=<address>`, never an access token. The app then runs the application-first (now PKCE-capable) flow itself. ## Tests `bundle exec rspec` — 350 examples, 0 failures. Part of #254.
raucao added the
integration
remotestorage
label 2026-11-02 09:01:53 +00:00
raucao force-pushed feature/rs_device_tokens from 25856a7ca7 to e3bf932c51 2026-11-02 12:41:26 +00:00 Compare
raucao changed title from Store per-device user agent for remoteStorage authorizations to Per-device remoteStorage tokens: user agent and supersede on consent 2026-11-02 13:07:48 +00:00
raucao added the feature label 2026-11-02 13:26:48 +00:00
raucao force-pushed feature/rs_device_tokens from 44e4488a4f to 918d2622c6 2026-11-02 13:43:48 +00:00 Compare
raucao changed title from Per-device remoteStorage tokens: user agent and supersede on consent to Store per-device user agent for remoteStorage authorizations 2026-11-02 13:45:36 +00:00
raucao marked the pull request as work in progress 2026-11-02 19:00:04 +00:00
raucao force-pushed feature/rs_device_tokens from 918d2622c6 to c5b8a49b5f 2026-11-03 04:08:23 +00:00 Compare
raucao force-pushed feature/rs_device_tokens from c5b8a49b5f to a2273f0c79 2026-11-03 05:18:40 +00:00 Compare
raucao force-pushed feature/rs_device_tokens from a2273f0c79 to 7bfde9eb5a 2026-11-03 07:44:45 +00:00 Compare
raucao added 3 commits 2026-11-03 08:02:08 +00:00
- Add user_agent to remote_storage_authorizations and rs_authorization_codes
- Capture the browser's user agent at consent, carry it on the authorization
  code, and store it on the authorization when the code is exchanged
- Store it directly for the implicit flow too

With the reuse shortcut gone, each authorization is already a distinct
per-device token; this adds the metadata needed to label and display them.

Part of #254
Add an explicit spec for the storage-first handoff (remoteStorage spec
section 11): launching an app passes only `#remotestorage=<address>`,
never an access token. The app then runs the application-first
(now PKCE-capable) flow itself.

Part of #254
Real-world user agents (in-app browsers, Android WebView variants) commonly
exceed 255 characters. On PostgreSQL that would raise and 500 the consent
POST and token exchange; SQLite dev/test does not enforce the limit, so it
went unnoticed. Use text columns for user_agent on both tables.

Part of #254
raucao force-pushed feature/rs_device_tokens from 7bfde9eb5a to 3dcd263d43 2026-11-03 08:02:08 +00:00 Compare
raucao added 10 commits 2026-11-03 16:37:23 +00:00
- Rework RsAuthComponent into a card that shows the app, its device, an
  access summary and the permission status
- Group connected apps by app and device, so repeated authorizations for
  the same app and device (e.g. after a browser update) are shown together,
  each with its own revoke action
- Add RsAuthDetailsModalComponent with the full scope list, device,
  connected tokens and permission expiry, plus Launch and Revoke actions
  (built on the existing ModalComponent)
- Add RemoteStorageAuthorization#device_name (parsed from the user agent)
  and #expired?

Part of #254
Replace the hand-rolled user-agent regexes with the device_detector gem.
Its UA database recognises many more clients (and, e.g., GNOME Web when
its UA carries the Epiphany token). WebKit "Safari" user agents on Linux
(WebKitGTK, which GNOME Web sends) are labelled "WebKit on Linux", since
Safari never runs on Linux.

Part of #254
- One card per app (grouped by client_id) showing distinct device and
  category counts; the whole card opens the details modal (with hover and
  focus highlight) instead of a separate Details button
- Details modal: access list styled like the OAuth consent dialog via a
  shared RsScopeListComponent, plus per-token device, connected date and
  expiry, each with its own Revoke
- "folder" -> "category" in the card, modal, consent dialog and the
  auth-created notification
- Make revoke a real DELETE: it was a GET link that Turbo 8's
  prefetch-on-hover fired on its own, silently deleting authorizations.
  Missing or foreign authorizations now return 404 instead of 500.
- Move "Launch app" to the app level
  (GET /services/storage/apps/:client_id/launch); no token id in the URL

Part of #254
- Move the app display name and a root-access helper onto
  RemoteStorageAuthorization, used by both components and the controller,
  removing the duplicated fallback chain and the unused OauthHelper includes
- Summarise the card's categories from the union of the app's authorizations'
  scopes, so an older token with broader access is not understated

Part of #254
Show the union of the app's authorizations' scopes in the modal's Access
section too, so it matches the card's summary, and cover the union
summary with a feature spec.

Part of #254
Polish the storage dashboard and details modal
CI / Test (pull_request) Successful in 44s
d94fda6d26
Visual refinement pass on the connected-apps dashboard introduced for #254.

Card:
- Restructure into a header row (app icon, name, host, chevron) with the
  device/category summary as a full-width footer, so the icon aligns with
  the name and the metrics sit on a consistent baseline
- Always show the host alongside the app name, except when it is identical
- Render the icon fallback as a neutral rounded tile instead of a faint
  watermark, and stop distorting real icons (object-contain)
- Summarise the union of the app's scopes, with monitor/folder icons

Details modal:
- Replace the duplicated blue buttons with a secondary Close and a primary
  Launch app, split 50:50 on desktop like the consent dialog
- Tighten the header, section spacing and device rows; hide a redundant host
- Add exact date/time tooltips to the connected and expiry labels
- Align the scope-list folder icons with their labels

Misc:
- Use fewer near-identical grays across the cards and modal
- Drop the redundant top margin on the app grid

Part of #254
Tokens issued before user agents were captured cannot be attributed to a
single device, and the per-app tokens issued earlier could even be reused
from several devices at once.

- Add RemoteStorageAuthorization#device_label, falling back to
  "Unknown device(s)" so the card and the details modal share one source
- Show a lower-bound device count with a "+" whenever an app has such a
  token, so it reads as "could be more" instead of claiming a number we
  cannot support
- Drop the now-redundant device-name wrapper from the details modal

Part of #254
Revoking a device redirected away from the storage dashboard, which closed the
details modal and reloaded the page. Refreshing the affected parts instead
keeps the modal open and shows the change where it happened.

- Extract the card and the modal's access list into their own components, so
  either can be re-rendered without touching the modal's open state, and share
  the group summaries between the components
- Derive the app's DOM ids from its client_id (the grouping key) and the device
  row ids from the authorization, through one helper used by both the templates
  and the controller
- Revoke one of several devices as a Turbo Stream: remove the row and refresh
  the card behind the modal and the access list
- Revoke an app's last device with a redirect, so the dashboard re-renders
  itself and grouping, sorting and the empty state stay in one place
- Fade the removed row out, deferring Turbo's own removal until the animation
  has ended

Part of #254
Show device timestamps in the reader's local time
CI / Test (pull_request) Successful in 48s
Release Drafter / Update release notes draft (pull_request) Successful in 3s
17bad40bf4
The exact issuance and expiry times in the device rows' hover titles were
rendered in UTC, which reads as wrong to anyone not living there.

- Mark the dates with a <time> element carrying the absolute (UTC) timestamp,
  rather than a custom data attribute whose name claimed to hold local time
- Rewrite those titles in the browser's own zone, keeping the server's UTC
  rendering as the fallback for when JavaScript is unavailable
- Only convert values that carry an explicit offset, so a date-only <time> is
  not read as UTC midnight and shifted onto the previous day
- Give the revoke button a little more room from the device name and dates

Part of #254
Merge pull request 'Storage dashboard: connected-app card and details modal' (#258) from feature/rs_storage_dashboard into feature/rs_device_tokens
CI / Test (pull_request) Successful in 42s
Release Drafter / Update release notes draft (pull_request) Successful in 2s
e6b7a55518
Reviewed-on: #258
raucao marked the pull request as ready for review 2026-11-03 16:37:31 +00:00
raucao merged commit 19b4dcfb46 into feature/rs_auth_pkce 2026-11-03 16:39:11 +00:00
raucao deleted branch feature/rs_device_tokens 2026-11-03 16:39:11 +00:00
raucao added the kredits-2 label 2026-11-03 16:43:02 +00:00
Sign in to join this conversation.