Commit 99adb3d
fix(passkey): unbreak registration — route mount + localhost gate (#63)
* fix(passkey): mount /api/passkey/register/* at the protected-group root
The two register routes were nested inside r.Route("/settings", ...),
so their effective paths were /settings/api/passkey/register/{begin,finish}.
The frontend (passkey-registration.js and the inline JS in
user_pages.templ) calls /api/passkey/register/begin, matching the public
/api/passkey/login/* routes — and every call 404'd:
POST http://localhost:3000/api/passkey/register/begin → 404
Move the two register endpoints up one level so they peer with logout and
the root redirect inside the protected group. They still pick up RequireAuth,
RequirePasswordChange, InjectIntegrationStatus, and the 60s timeout from
that group's middleware — auth is enforced by the group, not the URL
prefix. The PasskeyDelete endpoint stays at /settings/profile/passkey/delete
because it's a profile-page action, not a passkey-API call.
Result: passkey URLs are symmetric — /api/passkey/login/* (public) and
/api/passkey/register/* (authenticated).
Closes #44
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(passkey): stop excluding localhost from WebAuthn init
The gate at cmd/server/main.go was
if cfg.WebAuthnRPID != "" && cfg.WebAuthnRPID != "localhost"
…which meant any dev box running `make dev` (BASE_URL=http://localhost:3000)
got an uninitialized WebAuthn manager, and every passkey registration
attempt 500'd with "WebAuthn not configured."
`localhost` is a valid RPID per the WebAuthn spec (Level 2 §4 / §13.4.8)
and is whitelisted as a secure origin by every browser specifically so
dev installs don't need a TLS cert and a real hostname. The
`go-webauthn/webauthn` library accepts it without complaint.
Surfaced while verifying the routing fix for #44 — the routing change
alone left the same user goal still broken because the handler
shortcuts on a nil manager before doing anything useful.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(passkey): address Copilot review on #63
- Warn at startup if WebAuthn RPID resolved to "localhost" *and* BASE_URL
was never explicitly set. Without this, an operator who forgot to
configure BASE_URL in production gets a working-looking Passkey UI that
fails at registration with an opaque origin-mismatch error from the
browser. The warning makes the misconfig findable in the journal.
- Set `Cache-Control: no-store` (+ `Pragma: no-cache` for old proxies) on
the PasskeyRegisterBegin response. The body carries a single-use
challenge + session_id bound to the requesting user; an intermediary
cache could surface the same challenge to a different user. The /finish
handler's per-user session-ID check would reject the cross-user case,
but defense-in-depth costs two header lines.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9db25e9 commit 99adb3d
2 files changed
Lines changed: 27 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
402 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
403 | 405 | | |
404 | 406 | | |
405 | 407 | | |
| |||
414 | 416 | | |
415 | 417 | | |
416 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
417 | 430 | | |
418 | 431 | | |
419 | | - | |
| 432 | + | |
420 | 433 | | |
421 | 434 | | |
422 | 435 | | |
| |||
523 | 536 | | |
524 | 537 | | |
525 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
526 | 545 | | |
527 | 546 | | |
528 | 547 | | |
| |||
544 | 563 | | |
545 | 564 | | |
546 | 565 | | |
547 | | - | |
548 | | - | |
549 | | - | |
| 566 | + | |
550 | 567 | | |
551 | 568 | | |
552 | 569 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
93 | 94 | | |
| 95 | + | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
| |||
0 commit comments