Repository navigation
feat: let apps say their name when they ask to be approved, and show it with the device - #1339
Conversation
|
No actionable comments were generated in the recent review.
|
| 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
Possibly related PRs
- dev-null-sh/dev-null.sh#1261: Adds tests for the signed device-listing API response, which this change updates with
app_name.
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: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull 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
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_namewhen they open/mobile/authorize, next todevice_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, likemacos:sh.dev-null.mac,ios:com.nativephp.devnullorandroid: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) andapp_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.GET /api/v1/devicesand the data export include it.app_name.Validation
composer test:lint,bun run test:lint: passcomposer test:types,composer test:type-coverage(100%): passbun run test:unit: 212 passedpest --parallel --ci --coverage --exactly=100.0): 5159 tests, 5157 passed. The 2 failures are inCommitSearchControllerTest, which this PR doesn't touch: they pass on their own, andproductionpasses with the same command. They look order-dependent (pgvector's HNSW index), see LimitationsVisual 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").
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 emptyios:is rejected. It changes nothing visible, so the screenshots still apply.Limitations
Locally, the full suite fails 2
CommitSearchControllerTesttests on this branch but not onproduction. 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