enrollment: actually emit enroll_uri from the admin endpoint
The previous commit's edit to the admin handler silently did not apply, so the endpoint still returned just the token. Caught by deploying and looking at the response rather than by trusting the build to have picked it up. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
fe3658e009
commit
5291bdd045
@@ -234,7 +234,17 @@ func serve(cfg *config.Config) error {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(w, `{"token":%q,"expires_in_s":86400}`+"\n", tok)
|
||||
// The whole bootstrap, not just the token: this is what gets pasted or turned into a
|
||||
// QR code, and assembling it here is what keeps an operator from transcribing a pin by
|
||||
// hand — a pin wrong by one character fails as an inscrutable TLS error days later.
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
enc := json.NewEncoder(w)
|
||||
enc.SetEscapeHTML(false) // the link is full of / and =; escaping them helps nobody
|
||||
_ = enc.Encode(map[string]any{
|
||||
"token": tok,
|
||||
"expires_in_s": 86400,
|
||||
"enroll_uri": ctl.EnrollmentLink(tok),
|
||||
})
|
||||
})
|
||||
adminSrv := &http.Server{Addr: cfg.AdminListen, Handler: admin, ReadHeaderTimeout: 10 * time.Second}
|
||||
go func() { errCh <- fmt.Errorf("admin: %w", adminSrv.ListenAndServe()) }()
|
||||
|
||||
Reference in New Issue
Block a user