Skip to content

Feature/editor auth and testing - #39

Merged
eigger merged 4 commits into
masterfrom
feature/editor-auth-and-testing
Jul 7, 2026
Merged

Feature/editor auth and testing#39
eigger merged 4 commits into
masterfrom
feature/editor-auth-and-testing

Conversation

@eigger

@eigger eigger commented Jul 7, 2026

Copy link
Copy Markdown
Owner

No description provided.

@eigger
eigger merged commit 1bc5f74 into master Jul 7, 2026
2 checks passed
@eigger
eigger deleted the feature/editor-auth-and-testing branch July 7, 2026 08:06
eigger added a commit that referenced this pull request Jul 7, 2026
* Add API token auth for non-browser API callers (Home Assistant rest_command)

The editor session-cookie gate added in #38/#39 blocks any client that can't
hold a cookie, breaking the documented Home Assistant rest_command power
control integration (§8.6) with a 401. Adds a long-lived Authorization:
Bearer <token> credential with the same scope as the admin session, viewable/
rotatable from editor Settings, and updates both install-device docs with the
required header.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Let device commands be addressed by pairing token, expose both tokens in Settings

Following up on the API token fix: HA still needed a separate authenticated
GET /api/devices call just to resolve a display's internal UUID before it
could call /command. The command route now accepts the pairing token
directly (already known — it's in the "Open display" URL), and both the
device token and the API token are shown together in editor Settings so
there's nothing left to look up via curl.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Simplify: drop separate API token, device pairing token self-authorizes its own /command

A dedicated admin-wide API token was redundant with the per-device pairing
token that's already required in the same URL — two secrets to manage for
one job. Now a device's own pairing token, when used in place of the
internal id in /api/devices/<token>/command, is sufficient on its own: no
Authorization header, no separate token to view/rotate. It only unlocks that
one device's command endpoint; every other /api/* route still needs the
admin session. Updated both install-device docs and the settings UI (now a
single "device token" field instead of two).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Remove unused server backup/restore routes leaking a raw HA token

Investigating whether the device pairing token belongs in device backups
turned up that the editor's actual "백업 내보내기/가져오기" buttons never call
GET/POST /api/devices/:id/backup|restore at all — they build and parse the
backup JSON entirely client-side (layout + basic settings only, no tokens),
matching the existing comment in editor.js. The server routes were dead code
that returned the Home Assistant long-lived access token in plaintext
(bypassing the masking /api/settings/ha applies), contradicting that same
comment's stated intent. Removed the routes and the now-unused
store.updateDeviceToken/updateToken statement.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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