fleet-manager: allow multiple WebAuthn origins (comma-separated RP_ORIGIN)

Passkeys bind to the exact scheme://host:port the browser used, so a single
configured origin fails "Error validating origin" when reached via a different
form (e.g. :9500 direct vs a 443 proxy). Split FLEET_MGR_RP_ORIGIN on commas so
several exact origins can be allowed. Single-value config is unchanged.
This commit is contained in:
Audiobuzz
2026-07-04 11:07:15 +00:00
parent 643ba6be2d
commit 76446edd75
+11 -1
View File
@@ -15,6 +15,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"sync" "sync"
"time" "time"
@@ -191,9 +192,18 @@ func newWebAuthn(cfg config) (*webauthn.WebAuthn, error) {
if cfg.rpID == "" || cfg.rpOrigin == "" { if cfg.rpID == "" || cfg.rpOrigin == "" {
return nil, fmt.Errorf("WebAuthn needs FLEET_MGR_RP_ID and FLEET_MGR_RP_ORIGIN (the admin UI hostname/origin)") return nil, fmt.Errorf("WebAuthn needs FLEET_MGR_RP_ID and FLEET_MGR_RP_ORIGIN (the admin UI hostname/origin)")
} }
// FLEET_MGR_RP_ORIGIN may list several exact origins (comma-separated) — e.g.
// the direct :9500 form and a 443-proxy form — since passkeys bind to the
// exact scheme://host:port the browser used. Each must match a real origin.
var origins []string
for _, o := range strings.Split(cfg.rpOrigin, ",") {
if o = strings.TrimSpace(o); o != "" {
origins = append(origins, o)
}
}
return webauthn.New(&webauthn.Config{ return webauthn.New(&webauthn.Config{
RPID: cfg.rpID, RPID: cfg.rpID,
RPDisplayName: cfg.rpDisplayName, RPDisplayName: cfg.rpDisplayName,
RPOrigins: []string{cfg.rpOrigin}, RPOrigins: origins,
}) })
} }