Skip to content

feat: let apps say their name when they ask to be approved, and show it with the device - #1339

Merged
mnapoli merged 4 commits into
productionfrom
feat/device-app-name
Oct 31, 2026
Merged

mnapoli merged 4 commits into
productionfrom
feat/device-app-name

Conversation

@mnapoli

@mnapoli mnapoli commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Settings → Devices only shows the device's name, so two apps on one Mac read the same ("Ada's MacBook Pro" twice), and third-party clients (CLIs, status bars) can't be told apart from ours. Apps can now say their own name with an optional app_name when they open /mobile/authorize, next to device_name. The approval page asks "Approve /dev/null for Mac on MacBook Pro?" and the Devices page lists the app first, the device after it.

Names can change, so apps can also send a stable app_id: their platform and bundle id, like macos:sh.dev-null.mac, ios:com.nativephp.devnull or android:com.nativephp.devnull. The iOS and Android apps get different ids, because they are different apps that happen to share a bundle id. Nothing shows the id yet: it is the stable way to tell apps apart, and a server-side list of official apps can label known ids later.

It is optional: apps that don't send it work as before, and their devices show the device name alone.

Changes

  • devices.app_name, nullable. Why: the Devices page and the approval page need it to tell apps apart. Who sees it: only the user, on those pages, in the signed API's device list and in their export. When it's deleted: with the device, when it's revoked or the account is deleted.
  • devices.app_id, nullable, at most 100 characters, in the form <platform>:<bundle id>. Why: names change, so it is the stable way to tell apps apart, and the list of official apps will build on it. Who sees it: only the user, in their export. It isn't in the page props or the API. When it's deleted: same as the name.
  • app_name (optional, at most 100 characters) and app_id (optional) go from the authorize request, through the approval form and the one-time code, to the device. Re-approving a key takes what the app sends this time.
  • The signed API's GET /api/v1/devices and the data export include it.
  • Knowledge base: the sign-in section says apps can send app_name.

Validation

  • composer test:lint, bun run test:lint: pass
  • composer test:types, composer test:type-coverage (100%): pass
  • bun run test:unit: 212 passed
  • Full suite with coverage (pest --parallel --ci --coverage --exactly=100.0): 5159 tests, 5157 passed. The 2 failures are in CommitSearchControllerTest, which this PR doesn't touch: they pass on their own, and production passes with the same command. They look order-dependent (pgvector's HNSW index), see Limitations
  • CI (lint, types, type coverage, tests): pass

Visual evidence

Local app, same seeded devices on both sides: three apps that send a name and one older app that doesn't ("devnull on iPhone").

Before (production) After
Devices, light Devices before, light, 1280 Devices after, light, 1280
Devices, dark Devices before, dark, 1280 Devices after, dark, 1280
Devices, 390px Devices before, light, 390 Devices after, light, 390
Approval, app sends a name Approval before, light, 1280 Approval after, light, 1280
Approval, 390px Approval before, light, 390 Approval after, light, 390

An app that doesn't send a name looks exactly as before on both pages. On phones the title wraps, so the device name is never cut off.

Device verification

No mobile interaction changes: the Devices row and the approval heading only gain text. Checked at 390px wide in Chromium emulation, not on a device: the Devices title and the approval heading both wrap, and Revoke stays centred.

Independent review

Independent agent review of 5db55fb..40637e3: CODE: PASS, VISUAL: PASS. The first round (83f4084) failed visually, because the device name was cut off at 390px. Fixed by wrapping the title.

app_id (40637e3..20d8656): CODE: PASS. The reviewer's hardening is applied: only <platform>:<bundle id> is accepted, so an empty ios: is rejected. It changes nothing visible, so the screenshots still apply.

Limitations

  • Locally, the full suite fails 2 CommitSearchControllerTest tests on this branch but not on production. They pass on their own, and this PR doesn't touch search. My guess: rolled-back inserts from earlier tests leave dead entries in the HNSW index, so the approximate search misses a row, depending on which tests share a process. Not confirmed, and not fixed here.

  • Apps choose their own name and id, like they already choose the device name: it's what the app says, not verified. Any client can send an official app's id. Labeling apps as official later can rely on the id, but labeling them as verified would need App Attest or Play Integrity.

  • The Mac app and the mobile app need to send it (separate PRs). Until then nothing changes on screen.

Summary by CodeRabbit

  • New Features
    • Mobile apps can provide an optional name and stable identifier during device authorization. The app name appears on the approval page and in device settings.
    • App names and identifiers are included in device exports; identifiers are not displayed.
  • Documentation
    • Updated the authorization and device settings descriptions to explain how app names and identifiers are handled.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e89cf3b9-487d-499d-afdc-1c83aeb98f98
Commits

Reviewing files that changed from the base of the PR and between 5db55fb and 20d8656.

Files selected for processing: 22
  • KNOWLEDGE_BASE.md
  • app/Actions/CreateAuthorizationCode.php
  • app/Actions/CreateDevice.php
  • app/Actions/CreateExport.php
  • app/Dto/AuthorizationCode.php
  • app/Dto/MobileAuthorization.php
  • app/Http/Requests/CreateMobileAuthorizationRequest.php
  • app/Http/Requests/ShowMobileAuthorizationRequest.php
  • app/Http/Resources/DeviceResource.php
  • app/Models/Device.php
  • database/migrations/2026_10_31_120000_add_app_to_devices_table.php
  • resources/js/pages/device/index.tsx
  • resources/js/pages/mobile-authorization/show.tsx
  • resources/js/types/device.ts
  • tests/Feature/Controllers/Api/DeviceControllerTest.php
  • tests/Feature/Controllers/DeviceControllerTest.php
  • tests/Feature/Controllers/ExportControllerTest.php
  • tests/Feature/Controllers/MobileAuthorizationControllerTest.php
  • tests/Unit/Actions/CreateAuthorizationCodeTest.php
  • tests/Unit/Actions/CreateDeviceTest.php
  • tests/Unit/Dto/AuthorizationCodeTest.php
  • tests/Unit/Models/DeviceTest.php

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Mobile authorization now accepts optional app names and IDs. The metadata passes through authorization codes into device records, appears in device displays, and is included in exports.

Changes: App identity lifecycle

Layer / File(s) Summary
Authorization metadata flow
app/Dto/MobileAuthorization.php, app/Http/Requests/*MobileAuthorizationRequest.php, app/Dto/AuthorizationCode.php, app/Actions/CreateAuthorizationCode.php, tests/Feature/Controllers/MobileAuthorizationControllerTest.php, tests/Unit/Actions/CreateAuthorizationCodeTest.php, tests/Unit/Dto/AuthorizationCodeTest.php
Authorization requests validate and pass optional app_name and app_id values into authorization data and cached codes. Tests cover populated and absent values, along with invalid inputs.
Device storage and response data
database/migrations/*_add_app_to_devices_table.php, app/Models/Device.php, app/Actions/CreateDevice.php, app/Http/Resources/DeviceResource.php, app/Actions/CreateExport.php, tests/Unit/Actions/CreateDeviceTest.php, tests/Unit/Models/DeviceTest.php, tests/Feature/Controllers/*DeviceControllerTest.php, tests/Feature/Controllers/ExportControllerTest.php
The device table and model add app metadata. Device creation stores it, and device responses and exports include app metadata. Tests check stored values and response fields.
App names in approval and device views
resources/js/pages/mobile-authorization/show.tsx, resources/js/pages/device/index.tsx, resources/js/types/device.ts, KNOWLEDGE_BASE.md
The approval page and device list display the app name with the device name when an app name is present. The device type and documentation describe the added metadata and display.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MobileAuthorizationRequest
  participant MobileAuthorization
  participant CreateAuthorizationCode
  participant AuthorizationCodeCache
  participant CreateDevice
  participant DeviceRecord
  MobileAuthorizationRequest->>MobileAuthorization: Pass app_name and app_id
  MobileAuthorization->>CreateAuthorizationCode: Provide authorization metadata
  CreateAuthorizationCode->>AuthorizationCodeCache: Store app_name and app_id
  AuthorizationCodeCache->>CreateDevice: Supply authorization code data
  CreateDevice->>DeviceRecord: Store app_id and app_name
Loading

Possibly related PRs

Suggested reviewers: simonhamp, nunomaduro

Merge Risk: Minimal · up to 20d86

The app metadata flow has no identified merge-blocking issue. The migration follows the project’s forward-only policy, and the create request validates both new fields.

Security architecture risk: Low · up to 20d86

The change adds optional, client-supplied app labels without replacing the key and PKCE checks that determine access. The main considerations are keeping those labels distinct from verified identity and deploying the added database columns before the new application code.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — Stored metadata follows the existing user's devices. Web and API lists query the current user's device relationship, and exports query the supplied user's devices. Consequently, existing authorized API clients also receive app names for that user's other devices; persisted app_id remains excluded from ordinary device responses.

Security Findings and Attack Paths

  • inferred — A client can choose a misleading app label, but the base already allowed a client-chosen device name in the same approval heading. The new label does not bypass approval, replace the displayed fingerprint, or weaken redemption checks. The inspected comparison does not establish an introduced or materially worsened impersonation attack path.

Trust Boundaries and Controls

  • observed — Authorization authority still depends on the signed key fingerprint, PKCE verifier, cached user binding, and user existence. App metadata is validated on initiation and approval but does not participate in those authority checks. The approval form retains its CSRF token and explicit user action.

Resilience and Maintainability Implications

  • observed — Redemption retains the existing claim-marker, cache-removal, then database-update ordering. A database failure can consume the code before a device is saved, and concurrent approvals for one fingerprint retain last-writer behavior; both predate this PR. The new metadata is written with the existing device attributes, and device revocation deletes the containing row. Cache-backend atomicity was not independently established.

Hardening Proposals

  • proposed — If a future official-app list adds trust badges or privileges, require an authenticated binding to the app publisher rather than treating a matching client-supplied app_id as proof of identity. Keep current names and IDs explicitly descriptive.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: apps can provide a name during approval, and the name appears with the device.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 10 functions across 21 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@mnapoli
mnapoli marked this pull request as ready for review October 31, 2026 16:29
@mnapoli
mnapoli merged commit 3c7e4bb into production Oct 31, 2026
11 of 12 checks passed
@mnapoli
mnapoli deleted the feat/device-app-name branch October 31, 2026 16:39
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