From 28b2d1cb3f1bb8d956f2fc181a3a7510d319882d Mon Sep 17 00:00:00 2001 From: Josh Allmann Date: Thu, 12 Nov 2026 00:31:07 -0800 Subject: [PATCH 1/3] Support authenticated outbound ticket redemption --- .../testdata/cli/orchestrator-help.golden | 2 + docs/orchestrator.md | 6 +++ orchestrator/app.go | 18 ++++++++- orchestrator/app_test.go | 19 +++++++++ redemption/http.go | 10 ++++- redemption/http_test.go | 40 +++++++++++++++++++ 6 files changed, 92 insertions(+), 3 deletions(-) diff --git a/cmd/livepeer/testdata/cli/orchestrator-help.golden b/cmd/livepeer/testdata/cli/orchestrator-help.golden index 89ebc21..81f469b 100644 --- a/cmd/livepeer/testdata/cli/orchestrator-help.golden +++ b/cmd/livepeer/testdata/cli/orchestrator-help.golden @@ -28,6 +28,7 @@ Flags: --bootstrap-secret-file string File containing runner bootstrap credential (env: LIVEPEER_ORCHESTRATOR_BOOTSTRAP_SECRET_FILE) --runner-config string Static runner TOML path (env: LIVEPEER_ORCHESTRATOR_RUNNER_CONFIG) --redeemer-url string Remote winning-ticket redeemer base URL (env: LIVEPEER_ORCHESTRATOR_REDEEMER_URL) + --redeemer-headers-file string Owner-only ticket submission headers file (env: LIVEPEER_ORCHESTRATOR_REDEEMER_HEADERS_FILE) --redeemer-grants strings Private remote redeemer IP[:port] or CIDR grants (env: LIVEPEER_ORCHESTRATOR_REDEEMER_GRANTS) --max-pending-tickets int Maximum unsettled winning tickets (env: LIVEPEER_ORCHESTRATOR_MAX_PENDING_TICKETS) (default 100000) --max-tickets-per-recipient int Maximum unsettled tickets per recipient (env: LIVEPEER_ORCHESTRATOR_MAX_TICKETS_PER_RECIPIENT) (default 10000) @@ -57,5 +58,6 @@ Use "livepeer-orchestrator [command] --help" for more information about a comman Environment Variables: LIVEPEER_ORCHESTRATOR_BOOTSTRAP_SECRET Dynamic runner bootstrap credential + LIVEPEER_ORCHESTRATOR_REDEEMER_HEADERS Headers authenticating winning-ticket submission LIVEPEER_ORCHESTRATOR_KEYSTORE_PASSWORD Keystore decryption password LIVEPEER_ORCHESTRATOR_RPC_URL diff --git a/docs/orchestrator.md b/docs/orchestrator.md index dfc176d..587f10d 100644 --- a/docs/orchestrator.md +++ b/docs/orchestrator.md @@ -173,3 +173,9 @@ forward durable winning tickets without unlocking an orchestrator wallet. Keep the payment database and chain/pricing settings; remove local wallet and transaction settings. Local redemption remains the default. See the [standalone redeemer guide](redeemer.md) for setup, capacity, and recovery. + +Remote ticket submission may authenticate with `RedeemerHeadersFile`, an owner-only +regular file using comma-separated `Header: value` entries, for example +`Authorization: Bearer `. `RedeemerHeaders` is also accepted +through secret configuration conventions. These headers are used only for the +configured no-redirect redemption destination and are omitted from printed config. diff --git a/orchestrator/app.go b/orchestrator/app.go index 7306027..62774a4 100644 --- a/orchestrator/app.go +++ b/orchestrator/app.go @@ -10,6 +10,7 @@ import ( "net" "net/http" "net/url" + "os" "os/signal" "strings" "sync" @@ -48,6 +49,8 @@ type Params struct { BootstrapSecretFile string `basepath:"source" secretfor:"BootstrapSecret" descr:"File containing runner bootstrap credential"` RunnerConfig string `basepath:"source" optional:"true" file:"true" descr:"Static runner TOML path"` RedeemerURL *url.URL `name:"redeemer-url" optional:"true" descr:"Remote winning-ticket redeemer base URL"` + RedeemerHeaders nodeconfig.Headers `optional:"true" secret:"true" descr:"Headers authenticating winning-ticket submission"` + RedeemerHeadersFile string `basepath:"source" secretfor:"RedeemerHeaders" descr:"Owner-only ticket submission headers file"` RedeemerGrants []string `optional:"true" descr:"Private remote redeemer IP[:port] or CIDR grants"` MaxPendingTickets int `default:"100000" min:"1" descr:"Maximum unsettled winning tickets"` MaxTicketsPerRecipient int `default:"10000" min:"1" descr:"Maximum unsettled tickets per recipient"` @@ -79,6 +82,19 @@ func (p Params) paymentsRequested() bool { } func (p Params) Validate() error { + if _, err := p.RedeemerHeaders.MarshalText(); err != nil { + return errors.New("invalid redemption submission headers") + } + if (len(p.RedeemerHeaders) > 0 || p.RedeemerHeadersFile != "") && p.RedeemerURL == nil { + return errors.New("redemption submission headers require remote redemption") + } + if p.RedeemerHeadersFile != "" { + info, err := os.Stat(p.RedeemerHeadersFile) + if err != nil || !info.Mode().IsRegular() || info.Mode().Perm()&0077 != 0 { + return errors.New("redemption header file must be an owner-only regular file") + } + } + if p.BootstrapSecret == "" && p.RunnerConfig == "" { return errors.New("bootstrap secret or static runner config is required: set LIVEPEER_ORCHESTRATOR_BOOTSTRAP_SECRET, supply --bootstrap-secret-file (or LIVEPEER_ORCHESTRATOR_BOOTSTRAP_SECRET_FILE), or supply --runner-config (or LIVEPEER_ORCHESTRATOR_RUNNER_CONFIG) with a static runner TOML file") } @@ -453,7 +469,7 @@ func Serve(parent context.Context, p Params, logOut io.Writer) (result error) { if e != nil { return e } - remote, e := redemption.NewHTTPDestination(p.RedeemerURL, policy, binding) + remote, e := redemption.NewHTTPDestination(p.RedeemerURL, policy, binding, http.Header(p.RedeemerHeaders)) if e != nil { return e } diff --git a/orchestrator/app_test.go b/orchestrator/app_test.go index e51a360..a10d440 100644 --- a/orchestrator/app_test.go +++ b/orchestrator/app_test.go @@ -746,3 +746,22 @@ func TestChainMismatchBeforeStorage(t *testing.T) { require.ErrorContains(t, Serve(t.Context(), p, io.Discard), "chain ID") require.NoDirExists(t, filepath.Dir(p.RedeemerDB)) } + +func TestRedeemerHeadersFileResolutionAndRedaction(t *testing.T) { + path := filepath.Join(t.TempDir(), "redemption-headers") + require.NoError(t, os.WriteFile(path, []byte("Authorization: Bearer submission-file-secret"), 0600)) + var p Params + require.NoError(t, (boa.Cmd[Params]{Params: &p, RawArgs: []string{"--redeemer-headers-file", path}}).Validate()) + require.Equal(t, "Bearer submission-file-secret", http.Header(p.RedeemerHeaders).Get("Authorization")) + output, err := execute(t, "--config=", "--redeemer-url", "https://redeemer.example", "--redeemer-headers-file", path, "--print-config") + require.NoError(t, err) + require.NotContains(t, output, "submission-file-secret") + require.NotContains(t, output, path) + _, err = execute(t, "--redeemer-headers", "Authorization: Bearer literal-secret", "--print-config") + require.Error(t, err) + require.NotContains(t, err.Error(), "literal-secret") + require.NoError(t, os.Chmod(path, 0644)) + p.RedeemerHeadersFile = path + p.RedeemerURL, _ = url.Parse("https://redeemer.example") + require.ErrorContains(t, p.Validate(), "owner-only") +} diff --git a/redemption/http.go b/redemption/http.go index ba083c9..021a82c 100644 --- a/redemption/http.go +++ b/redemption/http.go @@ -170,9 +170,10 @@ type HTTPDestination struct { endpoint string client *http.Client binding Binding + headers http.Header } -func NewHTTPDestination(u *url.URL, policy destination.Policy, b Binding) (*HTTPDestination, error) { +func NewHTTPDestination(u *url.URL, policy destination.Policy, b Binding, headers ...http.Header) (*HTTPDestination, error) { normalized, err := RedeemerURL(u) if err != nil { return nil, err @@ -182,7 +183,11 @@ func NewHTTPDestination(u *url.URL, policy destination.Policy, b Binding) (*HTTP return nil, err } client := &http.Client{Transport: policy.Transport(15 * time.Second), Timeout: 20 * time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }} - return &HTTPDestination{endpoint, client, b}, nil + h := make(http.Header) + if len(headers) > 0 && headers[0] != nil { + h = headers[0].Clone() + } + return &HTTPDestination{endpoint: endpoint, client: client, binding: b, headers: h}, nil } func (d *HTTPDestination) Close() { d.client.CloseIdleConnections() } @@ -196,6 +201,7 @@ func (d *HTTPDestination) Submit(ctx context.Context, t *pm.SignedTicket) error if err != nil { return errors.New("invalid redeemer request") } + req.Header = d.headers.Clone() req.Header.Set("Content-Type", "application/json") res, err := d.client.Do(req) if err != nil { diff --git a/redemption/http_test.go b/redemption/http_test.go index 1880fc9..30dcf46 100644 --- a/redemption/http_test.go +++ b/redemption/http_test.go @@ -361,3 +361,43 @@ func TestHTTPDestinationRejectsRedirectsAndBadAcknowledgments(t *testing.T) { }) } } + +func TestDestinationSubmissionHeadersAndRedirectIsolation(t *testing.T) { + ticket, _ := winningTicket(t, 1) + var observed string + target := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + observed = r.Header.Get("Authorization") + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(202) + json.NewEncoder(w).Encode(TicketResponse{ticket.Hash()}) + })) + defer target.Close() + u, _ := url.Parse(target.URL) + policy, err := destination.New("redeemer", []string{u.Host}) + require.NoError(t, err) + headers := http.Header{"Authorization": []string{"Bearer submission-test"}} + d, err := NewHTTPDestination(u, policy, Binding{ChainID: "1", Controller: common.HexToAddress("0x1000")}, headers) + require.NoError(t, err) + defer d.Close() + headers.Set("Authorization", "Bearer mutated") + require.NoError(t, d.Submit(t.Context(), ticket)) + require.Equal(t, "Bearer submission-test", observed) + empty, err := NewHTTPDestination(u, policy, Binding{}, http.Header(nil)) + require.NoError(t, err) + defer empty.Close() + require.NoError(t, empty.Submit(t.Context(), ticket)) + require.Empty(t, observed) + redirected := false + sink := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { redirected = true })) + defer sink.Close() + redirect := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, sink.URL, 307) })) + defer redirect.Close() + u, _ = url.Parse(redirect.URL) + policy, err = destination.New("redeemer", []string{u.Host}) + require.NoError(t, err) + d2, err := NewHTTPDestination(u, policy, Binding{}, http.Header{"Authorization": []string{"Bearer submission-test"}}) + require.NoError(t, err) + defer d2.Close() + require.Error(t, d2.Submit(t.Context(), ticket)) + require.False(t, redirected) +} From ac7f6e681bbd43668582c3e831f38e3ccc9ea0dc Mon Sep 17 00:00:00 2001 From: Josh Allmann Date: Thu, 12 Nov 2026 00:38:57 -0800 Subject: [PATCH 2/3] Use named redirect status in credential isolation test --- redemption/http_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redemption/http_test.go b/redemption/http_test.go index 30dcf46..a21f72c 100644 --- a/redemption/http_test.go +++ b/redemption/http_test.go @@ -390,7 +390,7 @@ func TestDestinationSubmissionHeadersAndRedirectIsolation(t *testing.T) { redirected := false sink := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { redirected = true })) defer sink.Close() - redirect := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, sink.URL, 307) })) + redirect := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, sink.URL, http.StatusTemporaryRedirect) })) defer redirect.Close() u, _ = url.Parse(redirect.URL) policy, err = destination.New("redeemer", []string{u.Host}) From 621fb3f7a99674e6c4c4c3624eba13e549e5ac3e Mon Sep 17 00:00:00 2001 From: Josh Allmann Date: Thu, 12 Nov 2026 00:40:23 -0800 Subject: [PATCH 3/3] Format redirect isolation test --- redemption/http_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/redemption/http_test.go b/redemption/http_test.go index a21f72c..5a436c0 100644 --- a/redemption/http_test.go +++ b/redemption/http_test.go @@ -390,7 +390,9 @@ func TestDestinationSubmissionHeadersAndRedirectIsolation(t *testing.T) { redirected := false sink := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { redirected = true })) defer sink.Close() - redirect := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, sink.URL, http.StatusTemporaryRedirect) })) + redirect := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, sink.URL, http.StatusTemporaryRedirect) + })) defer redirect.Close() u, _ = url.Parse(redirect.URL) policy, err = destination.New("redeemer", []string{u.Host})